From: Takashi Iwai Date: Thu, 17 Apr 2008 10:52:02 +0000 (+0200) Subject: [ALSA] Clean up snd_card_free*() X-Git-Tag: v2.6.26-rc1~1087^2~31 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=f18638dcf0c481eca2430206ebcdc7295aec8623;p=linux-2.6-omap-h63xx.git [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 --- diff --git a/sound/core/init.c b/sound/core/init.c index 07acac77ea4..ac057341613 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 */ @@ -365,6 +369,9 @@ int snd_card_disconnect(struct snd_card *card) device_unregister(card->card_dev); 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;