Commit 2b29b13c authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[ALSA] Deprecate snd_card_free_in_thread()

Deprecated snd_card_free_in_thread(), replaced with
snd_card_free_when_closed().
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent c461482c
...@@ -1054,9 +1054,8 @@ ...@@ -1054,9 +1054,8 @@
<para> <para>
For a device which allows hotplugging, you can use For a device which allows hotplugging, you can use
<function>snd_card_free_in_thread</function>. This one will <function>snd_card_free_when_closed</function>. This one will
postpone the destruction and wait in a kernel-thread until all postpone the destruction until all devices are closed.
devices are closed.
</para> </para>
</section> </section>
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <linux/sched.h> /* wake_up() */ #include <linux/sched.h> /* wake_up() */
#include <linux/mutex.h> /* struct mutex */ #include <linux/mutex.h> /* struct mutex */
#include <linux/rwsem.h> /* struct rw_semaphore */ #include <linux/rwsem.h> /* struct rw_semaphore */
#include <linux/workqueue.h> /* struct workqueue_struct */
#include <linux/pm.h> /* pm_message_t */ #include <linux/pm.h> /* pm_message_t */
/* forward declarations */ /* forward declarations */
...@@ -132,7 +131,6 @@ struct snd_card { ...@@ -132,7 +131,6 @@ struct snd_card {
int shutdown; /* this card is going down */ int shutdown; /* this card is going down */
int free_on_last_close; /* free in context of file_release */ int free_on_last_close; /* free in context of file_release */
wait_queue_head_t shutdown_sleep; wait_queue_head_t shutdown_sleep;
struct work_struct free_workq; /* for free in workqueue */
struct device *dev; struct device *dev;
#ifdef CONFIG_PM #ifdef CONFIG_PM
...@@ -245,7 +243,6 @@ struct snd_card *snd_card_new(int idx, const char *id, ...@@ -245,7 +243,6 @@ struct snd_card *snd_card_new(int idx, const char *id,
int snd_card_disconnect(struct snd_card *card); int snd_card_disconnect(struct snd_card *card);
int snd_card_free(struct snd_card *card); int snd_card_free(struct snd_card *card);
int snd_card_free_when_closed(struct snd_card *card); int snd_card_free_when_closed(struct snd_card *card);
int snd_card_free_in_thread(struct snd_card *card);
int snd_card_register(struct snd_card *card); int snd_card_register(struct snd_card *card);
int snd_card_info_init(void); int snd_card_info_init(void);
int snd_card_info_done(void); int snd_card_info_done(void);
......
...@@ -81,8 +81,6 @@ static inline int init_info_for_card(struct snd_card *card) ...@@ -81,8 +81,6 @@ static inline int init_info_for_card(struct snd_card *card)
#define init_info_for_card(card) #define init_info_for_card(card)
#endif #endif
static void snd_card_free_thread(void * __card);
/** /**
* snd_card_new - create and initialize a soundcard structure * snd_card_new - create and initialize a soundcard structure
* @idx: card index (address) [0 ... (SNDRV_CARDS-1)] * @idx: card index (address) [0 ... (SNDRV_CARDS-1)]
...@@ -145,7 +143,6 @@ struct snd_card *snd_card_new(int idx, const char *xid, ...@@ -145,7 +143,6 @@ struct snd_card *snd_card_new(int idx, const char *xid,
INIT_LIST_HEAD(&card->ctl_files); INIT_LIST_HEAD(&card->ctl_files);
spin_lock_init(&card->files_lock); spin_lock_init(&card->files_lock);
init_waitqueue_head(&card->shutdown_sleep); init_waitqueue_head(&card->shutdown_sleep);
INIT_WORK(&card->free_workq, snd_card_free_thread, card);
#ifdef CONFIG_PM #ifdef CONFIG_PM
mutex_init(&card->power_lock); mutex_init(&card->power_lock);
init_waitqueue_head(&card->power_sleep); init_waitqueue_head(&card->power_sleep);
...@@ -413,53 +410,6 @@ int snd_card_free(struct snd_card *card) ...@@ -413,53 +410,6 @@ int snd_card_free(struct snd_card *card)
EXPORT_SYMBOL(snd_card_free); EXPORT_SYMBOL(snd_card_free);
static void snd_card_free_thread(void * __card)
{
struct snd_card *card = __card;
struct module * module = card->module;
if (!try_module_get(module)) {
snd_printk(KERN_ERR "unable to lock toplevel module for card %i in free thread\n", card->number);
module = NULL;
}
snd_card_free(card);
module_put(module);
}
/**
* snd_card_free_in_thread - call snd_card_free() in thread
* @card: soundcard structure
*
* This function schedules the call of snd_card_free() function in a
* work queue. When all devices are released (non-busy), the work
* is woken up and calls snd_card_free().
*
* When a card can be disconnected at any time by hotplug service,
* this function should be used in disconnect (or detach) callback
* instead of calling snd_card_free() directly.
*
* Returns - zero otherwise a negative error code if the start of thread failed.
*/
int snd_card_free_in_thread(struct snd_card *card)
{
if (card->files == NULL) {
snd_card_free(card);
return 0;
}
if (schedule_work(&card->free_workq))
return 0;
snd_printk(KERN_ERR "schedule_work() failed in snd_card_free_in_thread for card %i\n", card->number);
/* try to free the structure immediately */
snd_card_free(card);
return -EFAULT;
}
EXPORT_SYMBOL(snd_card_free_in_thread);
static void choose_default_id(struct snd_card *card) static void choose_default_id(struct snd_card *card)
{ {
int i, len, idx_flag = 0, loops = SNDRV_CARDS; int i, len, idx_flag = 0, loops = SNDRV_CARDS;
...@@ -742,9 +692,9 @@ EXPORT_SYMBOL(snd_card_file_add); ...@@ -742,9 +692,9 @@ EXPORT_SYMBOL(snd_card_file_add);
* *
* This function removes the file formerly added to the card via * This function removes the file formerly added to the card via
* snd_card_file_add() function. * snd_card_file_add() function.
* If all files are removed and the release of the card is * If all files are removed and snd_card_free_when_closed() was
* scheduled, it will wake up the the thread to call snd_card_free() * called beforehand, it processes the pending release of
* (see snd_card_free_in_thread() function). * resources.
* *
* Returns zero or a negative error code. * Returns zero or a negative error code.
*/ */
......
...@@ -211,7 +211,7 @@ static void __devexit snd_mpu401_pnp_remove(struct pnp_dev *dev) ...@@ -211,7 +211,7 @@ static void __devexit snd_mpu401_pnp_remove(struct pnp_dev *dev)
struct snd_card *card = (struct snd_card *) pnp_get_drvdata(dev); struct snd_card *card = (struct snd_card *) pnp_get_drvdata(dev);
snd_card_disconnect(card); snd_card_disconnect(card);
snd_card_free_in_thread(card); snd_card_free_when_closed(card);
} }
static struct pnp_driver snd_mpu401_pnp_driver = { static struct pnp_driver snd_mpu401_pnp_driver = {
......
...@@ -206,7 +206,7 @@ static void snd_pdacf_detach(struct pcmcia_device *link) ...@@ -206,7 +206,7 @@ static void snd_pdacf_detach(struct pcmcia_device *link)
snd_pdacf_powerdown(chip); snd_pdacf_powerdown(chip);
chip->chip_status |= PDAUDIOCF_STAT_IS_STALE; /* to be sure */ chip->chip_status |= PDAUDIOCF_STAT_IS_STALE; /* to be sure */
snd_card_disconnect(chip->card); snd_card_disconnect(chip->card);
snd_card_free_in_thread(chip->card); snd_card_free_when_closed(chip->card);
} }
/* /*
......
...@@ -65,7 +65,7 @@ static void vxpocket_release(struct pcmcia_device *link) ...@@ -65,7 +65,7 @@ static void vxpocket_release(struct pcmcia_device *link)
} }
/* /*
* destructor, called from snd_card_free_in_thread() * destructor, called from snd_card_free_when_closed()
*/ */
static int snd_vxpocket_dev_free(struct snd_device *device) static int snd_vxpocket_dev_free(struct snd_device *device)
{ {
...@@ -363,7 +363,7 @@ static void vxpocket_detach(struct pcmcia_device *link) ...@@ -363,7 +363,7 @@ static void vxpocket_detach(struct pcmcia_device *link)
chip->chip_status |= VX_STAT_IS_STALE; /* to be sure */ chip->chip_status |= VX_STAT_IS_STALE; /* to be sure */
snd_card_disconnect(chip->card); snd_card_disconnect(chip->card);
vxpocket_release(link); vxpocket_release(link);
snd_card_free_in_thread(chip->card); snd_card_free_when_closed(chip->card);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment