diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2018-10-10 15:35:02 +0900 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2018-10-10 12:11:50 +0200 |
commit | 3babca4555b20fc80aff4776662fb237257d9afd (patch) | |
tree | 10a967c09572ade5f331a61eae58b7a92e2666eb /sound/firewire/dice | |
parent | 873608dc6b5da7a2571419bfa10e0d088d39cee0 (diff) |
ALSA: firewire: simplify cleanup process when failing to register sound card
In former commits, .private_free callback releases resources just for
data transmission. This release function can be called without the
resources are actually allocated in error paths.
This commit applies a small refactoring to clean up codes in error
paths.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/dice')
-rw-r--r-- | sound/firewire/dice/dice.c | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/sound/firewire/dice/dice.c b/sound/firewire/dice/dice.c index c6b63e3f36a8..0f6dbcffe711 100644 --- a/sound/firewire/dice/dice.c +++ b/sound/firewire/dice/dice.c @@ -122,23 +122,14 @@ static void dice_card_strings(struct snd_dice *dice) strcpy(card->mixername, "DICE"); } -static void dice_free(struct snd_dice *dice) +static void dice_card_free(struct snd_card *card) { + struct snd_dice *dice = card->private_data; + snd_dice_stream_destroy_duplex(dice); snd_dice_transaction_destroy(dice); } -/* - * This module releases the FireWire unit data after all ALSA character devices - * are released by applications. This is for releasing stream data or finishing - * transactions safely. Thus at returning from .remove(), this module still keep - * references for the unit. - */ -static void dice_card_free(struct snd_card *card) -{ - dice_free(card->private_data); -} - static void do_registration(struct work_struct *work) { struct snd_dice *dice = container_of(work, struct snd_dice, dwork.work); @@ -151,6 +142,8 @@ static void do_registration(struct work_struct *work) &dice->card); if (err < 0) return; + dice->card->private_free = dice_card_free; + dice->card->private_data = dice; err = snd_dice_transaction_init(dice); if (err < 0) @@ -188,19 +181,10 @@ static void do_registration(struct work_struct *work) if (err < 0) goto error; - /* - * After registered, dice instance can be released corresponding to - * releasing the sound card instance. - */ - dice->card->private_free = dice_card_free; - dice->card->private_data = dice; dice->registered = true; return; error: - snd_dice_stream_destroy_duplex(dice); - snd_dice_transaction_destroy(dice); - snd_dice_stream_destroy_duplex(dice); snd_card_free(dice->card); dev_info(&dice->unit->device, "Sound card registration failed: %d\n", err); |