Skip to content

Commit 73c5685

Browse files
Uwe Kleine-Königtiwai
authored andcommitted
ALSA: core: Make snd_card_free_when_closed() 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. This cannot happen in snd_card_free() as card was dereferenced just before snd_card_free_when_closed() is called. So the error handling can be dropped there. 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 663f922 commit 73c5685

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

include/sound/core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ int snd_devm_card_new(struct device *parent, int idx, const char *xid,
289289
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);
292-
int snd_card_free_when_closed(struct snd_card *card);
292+
void snd_card_free_when_closed(struct snd_card *card);
293293
int snd_card_free_on_error(struct device *dev, int ret);
294294
void snd_card_set_id(struct snd_card *card, const char *id);
295295
int snd_card_register(struct snd_card *card);

sound/core/init.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -608,14 +608,14 @@ static int snd_card_do_free(struct snd_card *card)
608608
*
609609
* Return: zero if successful, or a negative error code
610610
*/
611-
int snd_card_free_when_closed(struct snd_card *card)
611+
void snd_card_free_when_closed(struct snd_card *card)
612612
{
613613
if (!card)
614-
return -EINVAL;
614+
return;
615615

616616
snd_card_disconnect(card);
617617
put_device(&card->card_dev);
618-
return 0;
618+
return;
619619
}
620620
EXPORT_SYMBOL(snd_card_free_when_closed);
621621

@@ -635,7 +635,6 @@ EXPORT_SYMBOL(snd_card_free_when_closed);
635635
int snd_card_free(struct snd_card *card)
636636
{
637637
DECLARE_COMPLETION_ONSTACK(released);
638-
int ret;
639638

640639
/* The call of snd_card_free() is allowed from various code paths;
641640
* a manual call from the driver and the call via devres_free, and
@@ -647,9 +646,8 @@ int snd_card_free(struct snd_card *card)
647646
return 0;
648647

649648
card->release_completion = &released;
650-
ret = snd_card_free_when_closed(card);
651-
if (ret)
652-
return ret;
649+
snd_card_free_when_closed(card);
650+
653651
/* wait, until all devices are ready for the free operation */
654652
wait_for_completion(&released);
655653

0 commit comments

Comments
 (0)