Commit c1a8d5f3 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: core: Enable proc module when CONFIG_MODULES=y

We used '#ifdef MODULE' for judging whether the system supports the
sound module or not, and /proc/asound/modules is created only when
'#ifdef MODULE' is true.  The check is not really appropriate, though,
because the flag means only for the sound core and the drivers are
still allowed to be built as modules even if 'MODULE' is not set in
sound/core/init.c.

For fixing the inconsistency, replace those ifdefs with 'ifdef
CONFIG_MODULES'.  One place for a NULL module check is rewritten with
IS_MODULE(CONFIG_SND) to be more intuitive.  It can't be changed to
CONFIG_MODULES; otherwise it would hit a WARN_ON() incorrectly.

This is a slight behavior change; the modules proc entry appears now
no matter whether the sound core is built-in or not as long as modules
are enabled on the kernel in general.  This can't be avoided due to
the nature of kernel builds.

Link: https://lore.kernel.org/r/20240520170349.2417900-1-xu.yang_2@nxp.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Tested-by: default avatarXu Yang <xu.yang_2@nxp.com>
Link: https://lore.kernel.org/r/20240522070442.17786-2-tiwai@suse.de
parent 39381fe7
...@@ -50,7 +50,7 @@ MODULE_PARM_DESC(slots, "Module names assigned to the slots."); ...@@ -50,7 +50,7 @@ MODULE_PARM_DESC(slots, "Module names assigned to the slots.");
static int module_slot_match(struct module *module, int idx) static int module_slot_match(struct module *module, int idx)
{ {
int match = 1; int match = 1;
#ifdef MODULE #ifdef CONFIG_MODULES
const char *s1, *s2; const char *s1, *s2;
if (!module || !*module->name || !slots[idx]) if (!module || !*module->name || !slots[idx])
...@@ -77,7 +77,7 @@ static int module_slot_match(struct module *module, int idx) ...@@ -77,7 +77,7 @@ static int module_slot_match(struct module *module, int idx)
if (!c1) if (!c1)
break; break;
} }
#endif /* MODULE */ #endif /* CONFIG_MODULES */
return match; return match;
} }
...@@ -311,9 +311,7 @@ static int snd_card_init(struct snd_card *card, struct device *parent, ...@@ -311,9 +311,7 @@ static int snd_card_init(struct snd_card *card, struct device *parent,
} }
card->dev = parent; card->dev = parent;
card->number = idx; card->number = idx;
#ifdef MODULE WARN_ON(IS_MODULE(CONFIG_SND) && !module);
WARN_ON(!module);
#endif
card->module = module; card->module = module;
INIT_LIST_HEAD(&card->devices); INIT_LIST_HEAD(&card->devices);
init_rwsem(&card->controls_rwsem); init_rwsem(&card->controls_rwsem);
...@@ -969,7 +967,7 @@ void snd_card_info_read_oss(struct snd_info_buffer *buffer) ...@@ -969,7 +967,7 @@ void snd_card_info_read_oss(struct snd_info_buffer *buffer)
#endif #endif
#ifdef MODULE #ifdef CONFIG_MODULES
static void snd_card_module_info_read(struct snd_info_entry *entry, static void snd_card_module_info_read(struct snd_info_entry *entry,
struct snd_info_buffer *buffer) struct snd_info_buffer *buffer)
{ {
...@@ -997,7 +995,7 @@ int __init snd_card_info_init(void) ...@@ -997,7 +995,7 @@ int __init snd_card_info_init(void)
if (snd_info_register(entry) < 0) if (snd_info_register(entry) < 0)
return -ENOMEM; /* freed in error path */ return -ENOMEM; /* freed in error path */
#ifdef MODULE #ifdef CONFIG_MODULES
entry = snd_info_create_module_entry(THIS_MODULE, "modules", NULL); entry = snd_info_create_module_entry(THIS_MODULE, "modules", NULL);
if (!entry) if (!entry)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment