aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/sound.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2010-11-23 11:43:19 -0500
committerTakashi Iwai <tiwai@suse.de>2010-11-23 23:53:25 -0500
commit03cfe6f57dc5c13ccdd235c23c80e3fa170f03d1 (patch)
treebabee2b37a52ec6b0c5f62f8e4783c937fd265d3 /sound/core/sound.c
parent109fef9edcc100952eec980acbc2e1295627fbab (diff)
ALSA: support module on-demand loading for seq and timer
If CONFIG_SND_DYNAMIC_MINORS is used, assign /dev/snd/seq and /dev/snd/timer the usual static minors, and export specific module aliases to generate udev module on-demand loading instructions: $ cat /lib/modules/2.6.33.4-smp/modules.devname # Device nodes to trigger on-demand module loading. microcode cpu/microcode c10:184 fuse fuse c10:229 ppp_generic ppp c108:0 tun net/tun c10:200 uinput uinput c10:223 dm_mod mapper/control c10:236 snd_timer snd/timer c116:33 snd_seq snd/seq c116:1 The last two lines instruct udev to create device nodes, even when the modules are not loaded at that time. As soon as userspace accesses any of these nodes, the in-kernel module-loader will load the module, and the device can be used. The header file minor calculation needed to be simplified to make __stringify() (supports only two indirections) in the MODULE_ALIAS macro work. This is part of systemd's effort to get rid of unconditional module load instructions and needless init scripts. Cc: Lennart Poettering <lennart@poettering.net> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/sound.c')
-rw-r--r--sound/core/sound.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 62a093efb453..345caea2d749 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -189,14 +189,22 @@ static const struct file_operations snd_fops =
189}; 189};
190 190
191#ifdef CONFIG_SND_DYNAMIC_MINORS 191#ifdef CONFIG_SND_DYNAMIC_MINORS
192static int snd_find_free_minor(void) 192static int snd_find_free_minor(int type)
193{ 193{
194 int minor; 194 int minor;
195 195
196 /* static minors for module auto loading */
197 if (type == SNDRV_DEVICE_TYPE_SEQUENCER)
198 return SNDRV_MINOR_SEQUENCER;
199 if (type == SNDRV_DEVICE_TYPE_TIMER)
200 return SNDRV_MINOR_TIMER;
201
196 for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) { 202 for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) {
197 /* skip minors still used statically for autoloading devices */ 203 /* skip static minors still used for module auto loading */
198 if (SNDRV_MINOR_DEVICE(minor) == SNDRV_MINOR_CONTROL || 204 if (SNDRV_MINOR_DEVICE(minor) == SNDRV_MINOR_CONTROL)
199 minor == SNDRV_MINOR_SEQUENCER) 205 continue;
206 if (minor == SNDRV_MINOR_SEQUENCER ||
207 minor == SNDRV_MINOR_TIMER)
200 continue; 208 continue;
201 if (!snd_minors[minor]) 209 if (!snd_minors[minor])
202 return minor; 210 return minor;
@@ -270,7 +278,7 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev,
270 preg->private_data = private_data; 278 preg->private_data = private_data;
271 mutex_lock(&sound_mutex); 279 mutex_lock(&sound_mutex);
272#ifdef CONFIG_SND_DYNAMIC_MINORS 280#ifdef CONFIG_SND_DYNAMIC_MINORS
273 minor = snd_find_free_minor(); 281 minor = snd_find_free_minor(type);
274#else 282#else
275 minor = snd_kernel_minor(type, card, dev); 283 minor = snd_kernel_minor(type, card, dev);
276 if (minor >= 0 && snd_minors[minor]) 284 if (minor >= 0 && snd_minors[minor])