[ALSA] Remove sound/driver.h
[sfrench/cifs-2.6.git] / sound / core / init.c
index db61037337427b9adc881868fa104c9ec015bc06..dc06e79ca09f29494515601a7b37a3e75d861472 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Initialization routines
- *  Copyright (c) by Jaroslav Kysela <perex@suse.cz>
+ *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  *
  *
  *   This program is free software; you can redistribute it and/or modify
  *
  */
 
-#include <sound/driver.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/file.h>
 #include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/ctype.h>
-#include <linux/pci.h>
 #include <linux/pm.h>
 
 #include <sound/core.h>
@@ -36,7 +34,7 @@
 static DEFINE_SPINLOCK(shutdown_lock);
 static LIST_HEAD(shutdown_files);
 
-static struct file_operations snd_shutdown_f_ops;
+static const struct file_operations snd_shutdown_f_ops;
 
 static unsigned int snd_cards_lock;    /* locked for registering/using */
 struct snd_card *snd_cards[SNDRV_CARDS];
@@ -44,6 +42,40 @@ EXPORT_SYMBOL(snd_cards);
 
 static DEFINE_MUTEX(snd_card_mutex);
 
+static char *slots[SNDRV_CARDS];
+module_param_array(slots, charp, NULL, 0444);
+MODULE_PARM_DESC(slots, "Module names assigned to the slots.");
+
+/* return non-zero if the given index is already reserved for another
+ * module via slots option
+ */
+static int module_slot_mismatch(struct module *module, int idx)
+{
+#ifdef MODULE
+       char *s1, *s2;
+       if (!module || !module->name || !slots[idx])
+               return 0;
+       s1 = slots[idx];
+       s2 = module->name;
+       /* compare module name strings
+        * hyphens are handled as equivalent with underscore
+        */
+       for (;;) {
+               char c1 = *s1++;
+               char c2 = *s2++;
+               if (c1 == '-')
+                       c1 = '_';
+               if (c2 == '-')
+                       c2 = '_';
+               if (c1 != c2)
+                       return 1;
+               if (!c1)
+                       break;
+       }
+#endif
+       return 0;
+}
+
 #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
 int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag);
 EXPORT_SYMBOL(snd_mixer_oss_notify_callback);
@@ -116,6 +148,8 @@ struct snd_card *snd_card_new(int idx, const char *xid,
                for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++)
                        /* idx == -1 == 0xffff means: take any free slot */
                        if (~snd_cards_lock & idx & 1<<idx2) {
+                               if (module_slot_mismatch(module, idx2))
+                                       continue;
                                idx = idx2;
                                if (idx >= snd_ecards_limit)
                                        snd_ecards_limit = idx + 1;
@@ -244,7 +278,7 @@ static int snd_disconnect_fasync(int fd, struct file *file, int on)
        return -ENODEV;
 }
 
-static struct file_operations snd_shutdown_f_ops =
+static const struct file_operations snd_shutdown_f_ops =
 {
        .owner =        THIS_MODULE,
        .llseek =       snd_disconnect_llseek,