summaryrefslogtreecommitdiff
path: root/sound/firewire/tascam
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2018-10-10 15:35:02 +0900
committerTakashi Iwai <tiwai@suse.de>2018-10-10 12:11:50 +0200
commit3babca4555b20fc80aff4776662fb237257d9afd (patch)
tree10a967c09572ade5f331a61eae58b7a92e2666eb /sound/firewire/tascam
parent873608dc6b5da7a2571419bfa10e0d088d39cee0 (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/tascam')
-rw-r--r--sound/firewire/tascam/tascam.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/sound/firewire/tascam/tascam.c b/sound/firewire/tascam/tascam.c
index f4f959128341..ef57fa4db323 100644
--- a/sound/firewire/tascam/tascam.c
+++ b/sound/firewire/tascam/tascam.c
@@ -85,17 +85,14 @@ static int identify_model(struct snd_tscm *tscm)
return 0;
}
-static void tscm_free(struct snd_tscm *tscm)
+static void tscm_card_free(struct snd_card *card)
{
+ struct snd_tscm *tscm = card->private_data;
+
snd_tscm_transaction_unregister(tscm);
snd_tscm_stream_destroy_duplex(tscm);
}
-static void tscm_card_free(struct snd_card *card)
-{
- tscm_free(card->private_data);
-}
-
static void do_registration(struct work_struct *work)
{
struct snd_tscm *tscm = container_of(work, struct snd_tscm, dwork.work);
@@ -105,6 +102,8 @@ static void do_registration(struct work_struct *work)
&tscm->card);
if (err < 0)
return;
+ tscm->card->private_free = tscm_card_free;
+ tscm->card->private_data = tscm;
err = identify_model(tscm);
if (err < 0)
@@ -136,18 +135,10 @@ static void do_registration(struct work_struct *work)
if (err < 0)
goto error;
- /*
- * After registered, tscm instance can be released corresponding to
- * releasing the sound card instance.
- */
- tscm->card->private_free = tscm_card_free;
- tscm->card->private_data = tscm;
tscm->registered = true;
return;
error:
- snd_tscm_transaction_unregister(tscm);
- snd_tscm_stream_destroy_duplex(tscm);
snd_card_free(tscm->card);
dev_info(&tscm->unit->device,
"Sound card registration failed: %d\n", err);