summaryrefslogtreecommitdiffstats
path: root/sound/firewire/oxfw
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/oxfw
parent873608dc6b5da7a2571419bfa10e0d088d39cee0 (diff)
downloadlinux-3babca4555b20fc80aff4776662fb237257d9afd.tar.gz
linux-3babca4555b20fc80aff4776662fb237257d9afd.tar.xz
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/oxfw')
-rw-r--r--sound/firewire/oxfw/oxfw.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c
index 14fe02a9ed5d..afb78d90384b 100644
--- a/sound/firewire/oxfw/oxfw.c
+++ b/sound/firewire/oxfw/oxfw.c
@@ -113,24 +113,15 @@ end:
return err;
}
-static void oxfw_free(struct snd_oxfw *oxfw)
+static void oxfw_card_free(struct snd_card *card)
{
+ struct snd_oxfw *oxfw = card->private_data;
+
snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);
if (oxfw->has_output)
snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);
}
-/*
- * 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 oxfw_card_free(struct snd_card *card)
-{
- oxfw_free(card->private_data);
-}
-
static int detect_quirks(struct snd_oxfw *oxfw)
{
struct fw_device *fw_dev = fw_parent_device(oxfw->unit);
@@ -204,6 +195,8 @@ static void do_registration(struct work_struct *work)
&oxfw->card);
if (err < 0)
return;
+ oxfw->card->private_free = oxfw_card_free;
+ oxfw->card->private_data = oxfw;
err = name_card(oxfw);
if (err < 0)
@@ -244,19 +237,10 @@ static void do_registration(struct work_struct *work)
if (err < 0)
goto error;
- /*
- * After registered, oxfw instance can be released corresponding to
- * releasing the sound card instance.
- */
- oxfw->card->private_free = oxfw_card_free;
- oxfw->card->private_data = oxfw;
oxfw->registered = true;
return;
error:
- snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);
- if (oxfw->has_output)
- snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);
snd_card_free(oxfw->card);
dev_info(&oxfw->unit->device,
"Sound card registration failed: %d\n", err);