diff options
Diffstat (limited to 'sound/core/init.c')
-rw-r--r-- | sound/core/init.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/sound/core/init.c b/sound/core/init.c index 2cb7099eb1e1..e3338d6071ef 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
@@ -19,7 +19,6 @@ | |||
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <sound/driver.h> | ||
23 | #include <linux/init.h> | 22 | #include <linux/init.h> |
24 | #include <linux/sched.h> | 23 | #include <linux/sched.h> |
25 | #include <linux/file.h> | 24 | #include <linux/file.h> |
@@ -43,6 +42,40 @@ EXPORT_SYMBOL(snd_cards); | |||
43 | 42 | ||
44 | static DEFINE_MUTEX(snd_card_mutex); | 43 | static DEFINE_MUTEX(snd_card_mutex); |
45 | 44 | ||
45 | static char *slots[SNDRV_CARDS]; | ||
46 | module_param_array(slots, charp, NULL, 0444); | ||
47 | MODULE_PARM_DESC(slots, "Module names assigned to the slots."); | ||
48 | |||
49 | /* return non-zero if the given index is already reserved for another | ||
50 | * module via slots option | ||
51 | */ | ||
52 | static int module_slot_mismatch(struct module *module, int idx) | ||
53 | { | ||
54 | #ifdef MODULE | ||
55 | char *s1, *s2; | ||
56 | if (!module || !module->name || !slots[idx]) | ||
57 | return 0; | ||
58 | s1 = slots[idx]; | ||
59 | s2 = module->name; | ||
60 | /* compare module name strings | ||
61 | * hyphens are handled as equivalent with underscore | ||
62 | */ | ||
63 | for (;;) { | ||
64 | char c1 = *s1++; | ||
65 | char c2 = *s2++; | ||
66 | if (c1 == '-') | ||
67 | c1 = '_'; | ||
68 | if (c2 == '-') | ||
69 | c2 = '_'; | ||
70 | if (c1 != c2) | ||
71 | return 1; | ||
72 | if (!c1) | ||
73 | break; | ||
74 | } | ||
75 | #endif | ||
76 | return 0; | ||
77 | } | ||
78 | |||
46 | #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) | 79 | #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) |
47 | int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag); | 80 | int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag); |
48 | EXPORT_SYMBOL(snd_mixer_oss_notify_callback); | 81 | EXPORT_SYMBOL(snd_mixer_oss_notify_callback); |
@@ -115,6 +148,8 @@ struct snd_card *snd_card_new(int idx, const char *xid, | |||
115 | for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++) | 148 | for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++) |
116 | /* idx == -1 == 0xffff means: take any free slot */ | 149 | /* idx == -1 == 0xffff means: take any free slot */ |
117 | if (~snd_cards_lock & idx & 1<<idx2) { | 150 | if (~snd_cards_lock & idx & 1<<idx2) { |
151 | if (module_slot_mismatch(module, idx2)) | ||
152 | continue; | ||
118 | idx = idx2; | 153 | idx = idx2; |
119 | if (idx >= snd_ecards_limit) | 154 | if (idx >= snd_ecards_limit) |
120 | snd_ecards_limit = idx + 1; | 155 | snd_ecards_limit = idx + 1; |
@@ -304,8 +339,8 @@ int snd_card_disconnect(struct snd_card *card) | |||
304 | list_add(&mfile->shutdown_list, &shutdown_files); | 339 | list_add(&mfile->shutdown_list, &shutdown_files); |
305 | spin_unlock(&shutdown_lock); | 340 | spin_unlock(&shutdown_lock); |
306 | 341 | ||
307 | fops_get(&snd_shutdown_f_ops); | ||
308 | mfile->file->f_op = &snd_shutdown_f_ops; | 342 | mfile->file->f_op = &snd_shutdown_f_ops; |
343 | fops_get(mfile->file->f_op); | ||
309 | 344 | ||
310 | mfile = mfile->next; | 345 | mfile = mfile->next; |
311 | } | 346 | } |