Skip to content

Commit c1a8d5f

Browse files
committed
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/[email protected] Signed-off-by: Takashi Iwai <[email protected]> Tested-by: Xu Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 39381fe commit c1a8d5f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

sound/core/init.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ MODULE_PARM_DESC(slots, "Module names assigned to the slots.");
5050
static int module_slot_match(struct module *module, int idx)
5151
{
5252
int match = 1;
53-
#ifdef MODULE
53+
#ifdef CONFIG_MODULES
5454
const char *s1, *s2;
5555

5656
if (!module || !*module->name || !slots[idx])
@@ -77,7 +77,7 @@ static int module_slot_match(struct module *module, int idx)
7777
if (!c1)
7878
break;
7979
}
80-
#endif /* MODULE */
80+
#endif /* CONFIG_MODULES */
8181
return match;
8282
}
8383

@@ -311,9 +311,7 @@ static int snd_card_init(struct snd_card *card, struct device *parent,
311311
}
312312
card->dev = parent;
313313
card->number = idx;
314-
#ifdef MODULE
315-
WARN_ON(!module);
316-
#endif
314+
WARN_ON(IS_MODULE(CONFIG_SND) && !module);
317315
card->module = module;
318316
INIT_LIST_HEAD(&card->devices);
319317
init_rwsem(&card->controls_rwsem);
@@ -969,7 +967,7 @@ void snd_card_info_read_oss(struct snd_info_buffer *buffer)
969967

970968
#endif
971969

972-
#ifdef MODULE
970+
#ifdef CONFIG_MODULES
973971
static void snd_card_module_info_read(struct snd_info_entry *entry,
974972
struct snd_info_buffer *buffer)
975973
{
@@ -997,7 +995,7 @@ int __init snd_card_info_init(void)
997995
if (snd_info_register(entry) < 0)
998996
return -ENOMEM; /* freed in error path */
999997

1000-
#ifdef MODULE
998+
#ifdef CONFIG_MODULES
1001999
entry = snd_info_create_module_entry(THIS_MODULE, "modules", NULL);
10021000
if (!entry)
10031001
return -ENOMEM;

0 commit comments

Comments
 (0)