diff options
author | Takashi Iwai <tiwai@suse.de> | 2008-04-17 06:52:02 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2008-04-24 06:00:39 -0400 |
commit | f18638dcf0c481eca2430206ebcdc7295aec8623 (patch) | |
tree | aae439ed9228e26afcc8d39cfe8a374ece0d215e | |
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>
-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) | |||
311 | struct file *file; | 311 | struct file *file; |
312 | int err; | 312 | int err; |
313 | 313 | ||
314 | if (!card) | ||
315 | return -EINVAL; | ||
316 | |||
314 | spin_lock(&card->files_lock); | 317 | spin_lock(&card->files_lock); |
315 | if (card->shutdown) { | 318 | if (card->shutdown) { |
316 | spin_unlock(&card->files_lock); | 319 | spin_unlock(&card->files_lock); |
@@ -322,6 +325,7 @@ int snd_card_disconnect(struct snd_card *card) | |||
322 | /* phase 1: disable fops (user space) operations for ALSA API */ | 325 | /* phase 1: disable fops (user space) operations for ALSA API */ |
323 | mutex_lock(&snd_card_mutex); | 326 | mutex_lock(&snd_card_mutex); |
324 | snd_cards[card->number] = NULL; | 327 | snd_cards[card->number] = NULL; |
328 | snd_cards_lock &= ~(1 << card->number); | ||
325 | mutex_unlock(&snd_card_mutex); | 329 | mutex_unlock(&snd_card_mutex); |
326 | 330 | ||
327 | /* phase 2: replace file->f_op with special dummy operations */ | 331 | /* phase 2: replace file->f_op with special dummy operations */ |
@@ -366,6 +370,9 @@ int snd_card_disconnect(struct snd_card *card) | |||
366 | card->card_dev = NULL; | 370 | card->card_dev = NULL; |
367 | } | 371 | } |
368 | #endif | 372 | #endif |
373 | #ifdef CONFIG_PM | ||
374 | wake_up(&card->power_sleep); | ||
375 | #endif | ||
369 | return 0; | 376 | return 0; |
370 | } | 377 | } |
371 | 378 | ||
@@ -411,25 +418,10 @@ static int snd_card_do_free(struct snd_card *card) | |||
411 | return 0; | 418 | return 0; |
412 | } | 419 | } |
413 | 420 | ||
414 | static int snd_card_free_prepare(struct snd_card *card) | ||
415 | { | ||
416 | if (card == NULL) | ||
417 | return -EINVAL; | ||
418 | (void) snd_card_disconnect(card); | ||
419 | mutex_lock(&snd_card_mutex); | ||
420 | snd_cards[card->number] = NULL; | ||
421 | snd_cards_lock &= ~(1 << card->number); | ||
422 | mutex_unlock(&snd_card_mutex); | ||
423 | #ifdef CONFIG_PM | ||
424 | wake_up(&card->power_sleep); | ||
425 | #endif | ||
426 | return 0; | ||
427 | } | ||
428 | |||
429 | int snd_card_free_when_closed(struct snd_card *card) | 421 | int snd_card_free_when_closed(struct snd_card *card) |
430 | { | 422 | { |
431 | int free_now = 0; | 423 | int free_now = 0; |
432 | int ret = snd_card_free_prepare(card); | 424 | int ret = snd_card_disconnect(card); |
433 | if (ret) | 425 | if (ret) |
434 | return ret; | 426 | return ret; |
435 | 427 | ||
@@ -449,7 +441,7 @@ EXPORT_SYMBOL(snd_card_free_when_closed); | |||
449 | 441 | ||
450 | int snd_card_free(struct snd_card *card) | 442 | int snd_card_free(struct snd_card *card) |
451 | { | 443 | { |
452 | int ret = snd_card_free_prepare(card); | 444 | int ret = snd_card_disconnect(card); |
453 | if (ret) | 445 | if (ret) |
454 | return ret; | 446 | return ret; |
455 | 447 | ||