X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fcore%2Finit.c;h=39ed2e5bb0af1b4a5c4320d7f14300f08bc40b8e;hb=9464c7cf61b9433057924c36e6e02f303a00e768;hp=4d9258884e444c368be86da0c470a69726f2253d;hpb=41689045f6a3cbe0550e1d34e9cc20d2e8c432ba;p=linux-2.6.git diff --git a/sound/core/init.c b/sound/core/init.c index 4d9258884..39ed2e5bb 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -38,15 +38,12 @@ struct snd_shutdown_f_ops { struct snd_shutdown_f_ops *next; }; -static unsigned int snd_cards_lock; /* locked for registering/using */ -struct snd_card *snd_cards[SNDRV_CARDS]; -EXPORT_SYMBOL(snd_cards); - -static DEFINE_MUTEX(snd_card_mutex); +unsigned int snd_cards_lock = 0; /* locked for registering/using */ +struct snd_card *snd_cards[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = NULL}; +DEFINE_RWLOCK(snd_card_rwlock); #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); #endif #ifdef CONFIG_PROC_FS @@ -69,6 +66,7 @@ static inline int init_info_for_card(struct snd_card *card) snd_printd("unable to create card entry\n"); return err; } + entry->c.text.read_size = PAGE_SIZE; entry->c.text.read = snd_card_id_read; if (snd_info_register(entry) < 0) { snd_info_free_entry(entry); @@ -112,7 +110,7 @@ struct snd_card *snd_card_new(int idx, const char *xid, strlcpy(card->id, xid, sizeof(card->id)); } err = 0; - mutex_lock(&snd_card_mutex); + write_lock(&snd_card_rwlock); if (idx < 0) { int idx2; for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++) @@ -130,12 +128,12 @@ struct snd_card *snd_card_new(int idx, const char *xid, else err = -ENODEV; if (idx < 0 || err < 0) { - mutex_unlock(&snd_card_mutex); + write_unlock(&snd_card_rwlock); snd_printk(KERN_ERR "cannot find the slot for index %d (range 0-%i)\n", idx, snd_ecards_limit - 1); goto __error; } snd_cards_lock |= 1 << idx; /* lock it */ - mutex_unlock(&snd_card_mutex); + write_unlock(&snd_card_rwlock); card->number = idx; card->module = module; INIT_LIST_HEAD(&card->devices); @@ -171,19 +169,6 @@ struct snd_card *snd_card_new(int idx, const char *xid, return NULL; } -EXPORT_SYMBOL(snd_card_new); - -/* return non-zero if a card is already locked */ -int snd_card_locked(int card) -{ - int locked; - - mutex_lock(&snd_card_mutex); - locked = snd_cards_lock & (1 << card); - mutex_unlock(&snd_card_mutex); - return locked; -} - static loff_t snd_disconnect_llseek(struct file *file, loff_t offset, int orig) { return -ENODEV; @@ -251,9 +236,9 @@ int snd_card_disconnect(struct snd_card *card) spin_unlock(&card->files_lock); /* phase 1: disable fops (user space) operations for ALSA API */ - mutex_lock(&snd_card_mutex); + write_lock(&snd_card_rwlock); snd_cards[card->number] = NULL; - mutex_unlock(&snd_card_mutex); + write_unlock(&snd_card_rwlock); /* phase 2: replace file->f_op with special dummy operations */ @@ -313,8 +298,6 @@ int snd_card_disconnect(struct snd_card *card) return 0; } -EXPORT_SYMBOL(snd_card_disconnect); - /** * snd_card_free - frees given soundcard structure * @card: soundcard structure @@ -332,9 +315,9 @@ int snd_card_free(struct snd_card *card) if (card == NULL) return -EINVAL; - mutex_lock(&snd_card_mutex); + write_lock(&snd_card_rwlock); snd_cards[card->number] = NULL; - mutex_unlock(&snd_card_mutex); + write_unlock(&snd_card_rwlock); #ifdef CONFIG_PM wake_up(&card->power_sleep); @@ -370,15 +353,13 @@ int snd_card_free(struct snd_card *card) card->s_f_ops = s_f_ops->next; kfree(s_f_ops); } - mutex_lock(&snd_card_mutex); + write_lock(&snd_card_rwlock); snd_cards_lock &= ~(1 << card->number); - mutex_unlock(&snd_card_mutex); + write_unlock(&snd_card_rwlock); kfree(card); return 0; } -EXPORT_SYMBOL(snd_card_free); - static void snd_card_free_thread(void * __card) { struct snd_card *card = __card; @@ -424,8 +405,6 @@ int snd_card_free_in_thread(struct snd_card *card) return -EFAULT; } -EXPORT_SYMBOL(snd_card_free_in_thread); - static void choose_default_id(struct snd_card *card) { int i, len, idx_flag = 0, loops = SNDRV_CARDS; @@ -508,16 +487,16 @@ int snd_card_register(struct snd_card *card) snd_assert(card != NULL, return -EINVAL); if ((err = snd_device_register_all(card)) < 0) return err; - mutex_lock(&snd_card_mutex); + write_lock(&snd_card_rwlock); if (snd_cards[card->number]) { /* already registered */ - mutex_unlock(&snd_card_mutex); + write_unlock(&snd_card_rwlock); return 0; } if (card->id[0] == '\0') choose_default_id(card); snd_cards[card->number] = card; - mutex_unlock(&snd_card_mutex); + write_unlock(&snd_card_rwlock); init_info_for_card(card); #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) if (snd_mixer_oss_notify_callback) @@ -526,10 +505,8 @@ int snd_card_register(struct snd_card *card) return 0; } -EXPORT_SYMBOL(snd_card_register); - #ifdef CONFIG_PROC_FS -static struct snd_info_entry *snd_card_info_entry; +static struct snd_info_entry *snd_card_info_entry = NULL; static void snd_card_info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) @@ -538,7 +515,7 @@ static void snd_card_info_read(struct snd_info_entry *entry, struct snd_card *card; for (idx = count = 0; idx < SNDRV_CARDS; idx++) { - mutex_lock(&snd_card_mutex); + read_lock(&snd_card_rwlock); if ((card = snd_cards[idx]) != NULL) { count++; snd_iprintf(buffer, "%2i [%-15s]: %s - %s\n", @@ -549,7 +526,7 @@ static void snd_card_info_read(struct snd_info_entry *entry, snd_iprintf(buffer, " %s\n", card->longname); } - mutex_unlock(&snd_card_mutex); + read_unlock(&snd_card_rwlock); } if (!count) snd_iprintf(buffer, "--- no soundcards ---\n"); @@ -563,12 +540,12 @@ void snd_card_info_read_oss(struct snd_info_buffer *buffer) struct snd_card *card; for (idx = count = 0; idx < SNDRV_CARDS; idx++) { - mutex_lock(&snd_card_mutex); + read_lock(&snd_card_rwlock); if ((card = snd_cards[idx]) != NULL) { count++; snd_iprintf(buffer, "%s\n", card->longname); } - mutex_unlock(&snd_card_mutex); + read_unlock(&snd_card_rwlock); } if (!count) { snd_iprintf(buffer, "--- no soundcards ---\n"); @@ -586,11 +563,11 @@ static void snd_card_module_info_read(struct snd_info_entry *entry, struct snd_card *card; for (idx = 0; idx < SNDRV_CARDS; idx++) { - mutex_lock(&snd_card_mutex); + read_lock(&snd_card_rwlock); if ((card = snd_cards[idx]) != NULL) snd_iprintf(buffer, "%2i %s\n", idx, card->module->name); - mutex_unlock(&snd_card_mutex); + read_unlock(&snd_card_rwlock); } } #endif @@ -602,6 +579,7 @@ int __init snd_card_info_init(void) entry = snd_info_create_module_entry(THIS_MODULE, "cards", NULL); if (! entry) return -ENOMEM; + entry->c.text.read_size = PAGE_SIZE; entry->c.text.read = snd_card_info_read; if (snd_info_register(entry) < 0) { snd_info_free_entry(entry); @@ -612,6 +590,7 @@ int __init snd_card_info_init(void) #ifdef MODULE entry = snd_info_create_module_entry(THIS_MODULE, "modules", NULL); if (entry) { + entry->c.text.read_size = PAGE_SIZE; entry->c.text.read = snd_card_module_info_read; if (snd_info_register(entry) < 0) snd_info_free_entry(entry); @@ -665,8 +644,6 @@ int snd_component_add(struct snd_card *card, const char *component) return 0; } -EXPORT_SYMBOL(snd_component_add); - /** * snd_card_file_add - add the file to the file list of the card * @card: soundcard structure @@ -699,8 +676,6 @@ int snd_card_file_add(struct snd_card *card, struct file *file) return 0; } -EXPORT_SYMBOL(snd_card_file_add); - /** * snd_card_file_remove - remove the file from the file list * @card: soundcard structure @@ -742,8 +717,6 @@ int snd_card_file_remove(struct snd_card *card, struct file *file) return 0; } -EXPORT_SYMBOL(snd_card_file_remove); - #ifdef CONFIG_PM /** * snd_power_wait - wait until the power-state is changed. @@ -780,5 +753,4 @@ int snd_power_wait(struct snd_card *card, unsigned int power_state) return result; } -EXPORT_SYMBOL(snd_power_wait); #endif /* CONFIG_PM */