diff options
author | Takashi Iwai <tiwai@suse.de> | 2008-04-17 12:52:02 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2008-04-24 12:00:39 +0200 |
commit | f18638dcf0c481eca2430206ebcdc7295aec8623 (patch) | |
tree | aae439ed9228e26afcc8d39cfe8a374ece0d215e /sound/core | |
parent | 73d38b13ffb105ab633bd91969c8d218b2de38d4 (diff) |
[ALSA] Clean up snd_card_free*()
A little clean up of snd_card_free*().
Removed snd_card_free_prepare() since it's actually almost identical
with snd_card_disconnect().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/init.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/sound/core/init.c b/sound/core/init.c index 07acac77ea45..ac0573416130 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -311,6 +311,9 @@ int snd_card_disconnect(struct snd_card *card) struct file *file; int err; + if (!card) + return -EINVAL; + spin_lock(&card->files_lock); if (card->shutdown) { spin_unlock(&card->files_lock); @@ -322,6 +325,7 @@ int snd_card_disconnect(struct snd_card *card) /* phase 1: disable fops (user space) operations for ALSA API */ mutex_lock(&snd_card_mutex); snd_cards[card->number] = NULL; + snd_cards_lock &= ~(1 << card->number); mutex_unlock(&snd_card_mutex); /* phase 2: replace file->f_op with special dummy operations */ @@ -366,6 +370,9 @@ int snd_card_disconnect(struct snd_card *card) card->card_dev = NULL; } #endif +#ifdef CONFIG_PM + wake_up(&card->power_sleep); +#endif return 0; } @@ -411,25 +418,10 @@ static int snd_card_do_free(struct snd_card *card) return 0; } -static int snd_card_free_prepare(struct snd_card *card) -{ - if (card == NULL) - return -EINVAL; - (void) snd_card_disconnect(card); - mutex_lock(&snd_card_mutex); - snd_cards[card->number] = NULL; - snd_cards_lock &= ~(1 << card->number); - mutex_unlock(&snd_card_mutex); -#ifdef CONFIG_PM - wake_up(&card->power_sleep); -#endif - return 0; -} - int snd_card_free_when_closed(struct snd_card *card) { int free_now = 0; - int ret = snd_card_free_prepare(card); + int ret = snd_card_disconnect(card); if (ret) return ret; @@ -449,7 +441,7 @@ EXPORT_SYMBOL(snd_card_free_when_closed); int snd_card_free(struct snd_card *card) { - int ret = snd_card_free_prepare(card); + int ret = snd_card_disconnect(card); if (ret) return ret; |