Skip to content

Commit 663f922

Browse files
Uwe Kleine-Königtiwai
authored andcommitted
ALSA: core: Make snd_card_disconnect() return void
All callers from other files ignore the return value of this function. And it can only ever return a non-zero value if the parameter card is NULL. Move the check for card being NULL into snd_card_free_when_closed() to keep the previous behaviour. Note this isn't necessary for snd_card_disconnect_sync() because if card was NULL in there the dereference of card for dev_err() would oops the kernel. Replace this by an oops triggered by the dereference of card for spin_lock_irq(). Signed-off-by: Uwe Kleine-König <[email protected]> Reviewed-by: Jaroslav Kysela <[email protected]> Reviewed-by: Takashi Sakamoto <[email protected]> Acked-by: Geoff Levand <[email protected]> Acked-by: Thierry Reding <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 69218b5 commit 663f922

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

include/sound/core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ int snd_devm_card_new(struct device *parent, int idx, const char *xid,
286286
struct module *module, size_t extra_size,
287287
struct snd_card **card_ret);
288288

289-
int snd_card_disconnect(struct snd_card *card);
289+
void snd_card_disconnect(struct snd_card *card);
290290
void snd_card_disconnect_sync(struct snd_card *card);
291291
int snd_card_free(struct snd_card *card);
292292
int snd_card_free_when_closed(struct snd_card *card);

sound/core/init.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -489,17 +489,17 @@ static const struct file_operations snd_shutdown_f_ops =
489489
* Note: The current implementation replaces all active file->f_op with special
490490
* dummy file operations (they do nothing except release).
491491
*/
492-
int snd_card_disconnect(struct snd_card *card)
492+
void snd_card_disconnect(struct snd_card *card)
493493
{
494494
struct snd_monitor_file *mfile;
495495

496496
if (!card)
497-
return -EINVAL;
497+
return;
498498

499499
spin_lock(&card->files_lock);
500500
if (card->shutdown) {
501501
spin_unlock(&card->files_lock);
502-
return 0;
502+
return;
503503
}
504504
card->shutdown = 1;
505505

@@ -548,7 +548,6 @@ int snd_card_disconnect(struct snd_card *card)
548548
wake_up(&card->power_sleep);
549549
snd_power_sync_ref(card);
550550
#endif
551-
return 0;
552551
}
553552
EXPORT_SYMBOL(snd_card_disconnect);
554553

@@ -563,15 +562,7 @@ EXPORT_SYMBOL(snd_card_disconnect);
563562
*/
564563
void snd_card_disconnect_sync(struct snd_card *card)
565564
{
566-
int err;
567-
568-
err = snd_card_disconnect(card);
569-
if (err < 0) {
570-
dev_err(card->dev,
571-
"snd_card_disconnect error (%d), skipping sync\n",
572-
err);
573-
return;
574-
}
565+
snd_card_disconnect(card);
575566

576567
spin_lock_irq(&card->files_lock);
577568
wait_event_lock_irq(card->remove_sleep,
@@ -619,9 +610,10 @@ static int snd_card_do_free(struct snd_card *card)
619610
*/
620611
int snd_card_free_when_closed(struct snd_card *card)
621612
{
622-
int ret = snd_card_disconnect(card);
623-
if (ret)
624-
return ret;
613+
if (!card)
614+
return -EINVAL;
615+
616+
snd_card_disconnect(card);
625617
put_device(&card->card_dev);
626618
return 0;
627619
}

0 commit comments

Comments
 (0)