Skip to content

Commit f18638d

Browse files
committed
[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>
1 parent 73d38b1 commit f18638d

1 file changed

Lines changed: 9 additions & 17 deletions

File tree

‎sound/core/init.c‎

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ int snd_card_disconnect(struct snd_card *card)
311311
struct file *file;
312312
int err;
313313

314+
if (!card)
315+
return -EINVAL;
316+
314317
spin_lock(&card->files_lock);
315318
if (card->shutdown) {
316319
spin_unlock(&card->files_lock);
@@ -322,6 +325,7 @@ int snd_card_disconnect(struct snd_card *card)
322325
/* phase 1: disable fops (user space) operations for ALSA API */
323326
mutex_lock(&snd_card_mutex);
324327
snd_cards[card->number] = NULL;
328+
snd_cards_lock &= ~(1 << card->number);
325329
mutex_unlock(&snd_card_mutex);
326330

327331
/* phase 2: replace file->f_op with special dummy operations */
@@ -365,6 +369,9 @@ int snd_card_disconnect(struct snd_card *card)
365369
device_unregister(card->card_dev);
366370
card->card_dev = NULL;
367371
}
372+
#endif
373+
#ifdef CONFIG_PM
374+
wake_up(&card->power_sleep);
368375
#endif
369376
return 0;
370377
}
@@ -411,25 +418,10 @@ static int snd_card_do_free(struct snd_card *card)
411418
return 0;
412419
}
413420

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-
429421
int snd_card_free_when_closed(struct snd_card *card)
430422
{
431423
int free_now = 0;
432-
int ret = snd_card_free_prepare(card);
424+
int ret = snd_card_disconnect(card);
433425
if (ret)
434426
return ret;
435427

@@ -449,7 +441,7 @@ EXPORT_SYMBOL(snd_card_free_when_closed);
449441

450442
int snd_card_free(struct snd_card *card)
451443
{
452-
int ret = snd_card_free_prepare(card);
444+
int ret = snd_card_disconnect(card);
453445
if (ret)
454446
return ret;
455447

0 commit comments

Comments
 (0)