aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/init.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2006-06-23 08:38:26 -0400
committerJaroslav Kysela <perex@suse.cz>2006-09-23 04:37:03 -0400
commit2b29b13c5794f648cd5e839796496704d787f5a6 (patch)
treeb9753f2593aff429a8cca63e40f052a0fdd6aedb /sound/core/init.c
parentc461482c8072bb073e6146db320d3da85cdc89ad (diff)
[ALSA] Deprecate snd_card_free_in_thread()
Deprecated snd_card_free_in_thread(), replaced with snd_card_free_when_closed(). Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/core/init.c')
-rw-r--r--sound/core/init.c56
1 files changed, 3 insertions, 53 deletions
diff --git a/sound/core/init.c b/sound/core/init.c
index 5850d99d21e3..d7607a25acdf 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -81,8 +81,6 @@ static inline int init_info_for_card(struct snd_card *card)
81#define init_info_for_card(card) 81#define init_info_for_card(card)
82#endif 82#endif
83 83
84static void snd_card_free_thread(void * __card);
85
86/** 84/**
87 * snd_card_new - create and initialize a soundcard structure 85 * snd_card_new - create and initialize a soundcard structure
88 * @idx: card index (address) [0 ... (SNDRV_CARDS-1)] 86 * @idx: card index (address) [0 ... (SNDRV_CARDS-1)]
@@ -145,7 +143,6 @@ struct snd_card *snd_card_new(int idx, const char *xid,
145 INIT_LIST_HEAD(&card->ctl_files); 143 INIT_LIST_HEAD(&card->ctl_files);
146 spin_lock_init(&card->files_lock); 144 spin_lock_init(&card->files_lock);
147 init_waitqueue_head(&card->shutdown_sleep); 145 init_waitqueue_head(&card->shutdown_sleep);
148 INIT_WORK(&card->free_workq, snd_card_free_thread, card);
149#ifdef CONFIG_PM 146#ifdef CONFIG_PM
150 mutex_init(&card->power_lock); 147 mutex_init(&card->power_lock);
151 init_waitqueue_head(&card->power_sleep); 148 init_waitqueue_head(&card->power_sleep);
@@ -413,53 +410,6 @@ int snd_card_free(struct snd_card *card)
413 410
414EXPORT_SYMBOL(snd_card_free); 411EXPORT_SYMBOL(snd_card_free);
415 412
416static void snd_card_free_thread(void * __card)
417{
418 struct snd_card *card = __card;
419 struct module * module = card->module;
420
421 if (!try_module_get(module)) {
422 snd_printk(KERN_ERR "unable to lock toplevel module for card %i in free thread\n", card->number);
423 module = NULL;
424 }
425
426 snd_card_free(card);
427
428 module_put(module);
429}
430
431/**
432 * snd_card_free_in_thread - call snd_card_free() in thread
433 * @card: soundcard structure
434 *
435 * This function schedules the call of snd_card_free() function in a
436 * work queue. When all devices are released (non-busy), the work
437 * is woken up and calls snd_card_free().
438 *
439 * When a card can be disconnected at any time by hotplug service,
440 * this function should be used in disconnect (or detach) callback
441 * instead of calling snd_card_free() directly.
442 *
443 * Returns - zero otherwise a negative error code if the start of thread failed.
444 */
445int snd_card_free_in_thread(struct snd_card *card)
446{
447 if (card->files == NULL) {
448 snd_card_free(card);
449 return 0;
450 }
451
452 if (schedule_work(&card->free_workq))
453 return 0;
454
455 snd_printk(KERN_ERR "schedule_work() failed in snd_card_free_in_thread for card %i\n", card->number);
456 /* try to free the structure immediately */
457 snd_card_free(card);
458 return -EFAULT;
459}
460
461EXPORT_SYMBOL(snd_card_free_in_thread);
462
463static void choose_default_id(struct snd_card *card) 413static void choose_default_id(struct snd_card *card)
464{ 414{
465 int i, len, idx_flag = 0, loops = SNDRV_CARDS; 415 int i, len, idx_flag = 0, loops = SNDRV_CARDS;
@@ -742,9 +692,9 @@ EXPORT_SYMBOL(snd_card_file_add);
742 * 692 *
743 * This function removes the file formerly added to the card via 693 * This function removes the file formerly added to the card via
744 * snd_card_file_add() function. 694 * snd_card_file_add() function.
745 * If all files are removed and the release of the card is 695 * If all files are removed and snd_card_free_when_closed() was
746 * scheduled, it will wake up the the thread to call snd_card_free() 696 * called beforehand, it processes the pending release of
747 * (see snd_card_free_in_thread() function). 697 * resources.
748 * 698 *
749 * Returns zero or a negative error code. 699 * Returns zero or a negative error code.
750 */ 700 */