1
0
Fork 0

ALSA: hda - Fix undefined symbol due to builtin/module mixup

Even after the fix for leftover kconfig handling (commit f8f1becf),
the current code still doesn't handle properly the builtin/module
mixup case between the core snd-hda-codec and other codec drivers.
For example, when CONFIG_SND_HDA_INTEL=y and
CONFIG_SND_HDA_CODEC_HDMI=m, it'll end up with an unresolved symbol
snd_hda_parse_hdmi_codec.  This patch fixes the issue.

Now codec->parser points to the parser object *only* when a module
(either generic or HDMI parser) is loaded and bound.  When a builtin
symbol is used, codec->parser still points to NULL.  This is the
difference from the previous versions.

Fixes: f8f1becfa4 ('ALSA: hda - Fix leftover ifdef checks after modularization')
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
hifive-unleashed-5.1
Takashi Iwai 2014-02-10 11:43:41 +01:00
parent f88abaa0d0
commit ef8e39b51f
1 changed files with 16 additions and 16 deletions

View File

@ -1339,23 +1339,15 @@ get_hda_cvt_setup(struct hda_codec *codec, hda_nid_t nid)
/*
* Dynamic symbol binding for the codec parsers
*/
#ifdef MODULE
#define load_parser_sym(sym) ((int (*)(struct hda_codec *))symbol_request(sym))
#define unload_parser_addr(addr) symbol_put_addr(addr)
#else
#define load_parser_sym(sym) (sym)
#define unload_parser_addr(addr) do {} while (0)
#endif
#define load_parser(codec, sym) \
((codec)->parser = load_parser_sym(sym))
((codec)->parser = (int (*)(struct hda_codec *))symbol_request(sym))
static void unload_parser(struct hda_codec *codec)
{
if (codec->parser) {
unload_parser_addr(codec->parser);
codec->parser = NULL;
}
if (codec->parser)
symbol_put_addr(codec->parser);
codec->parser = NULL;
}
/*
@ -1620,12 +1612,20 @@ int snd_hda_codec_configure(struct hda_codec *codec)
patch = codec->preset->patch;
if (!patch) {
unload_parser(codec); /* to be sure */
if (is_likely_hdmi_codec(codec))
if (is_likely_hdmi_codec(codec)) {
#if IS_MODULE(CONFIG_SND_HDA_CODEC_HDMI)
patch = load_parser(codec, snd_hda_parse_hdmi_codec);
#if IS_ENABLED(CONFIG_SND_HDA_GENERIC)
if (!patch)
patch = load_parser(codec, snd_hda_parse_generic_codec);
#elif IS_BUILTIN(CONFIG_SND_HDA_CODEC_HDMI)
patch = snd_hda_parse_hdmi_codec;
#endif
}
if (!patch) {
#if IS_MODULE(CONFIG_SND_HDA_GENERIC)
patch = load_parser(codec, snd_hda_parse_generic_codec);
#elif IS_BUILTIN(CONFIG_SND_HDA_GENERIC)
patch = snd_hda_parse_generic_codec;
#endif
}
if (!patch) {
printk(KERN_ERR "hda-codec: No codec parser is available\n");
return -ENODEV;