summaryrefslogtreecommitdiff
path: root/sound/firewire/bebob
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/bebob
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/bebob')
-rw-r--r--sound/firewire/bebob/bebob.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/sound/firewire/bebob/bebob.c b/sound/firewire/bebob/bebob.c
index 3bc68499974a..672d13488454 100644
--- a/sound/firewire/bebob/bebob.c
+++ b/sound/firewire/bebob/bebob.c
@@ -126,8 +126,11 @@ end:
return err;
}
-static void bebob_free(struct snd_bebob *bebob)
+static void
+bebob_card_free(struct snd_card *card)
{
+ struct snd_bebob *bebob = card->private_data;
+
mutex_lock(&devices_mutex);
clear_bit(bebob->card_index, devices_used);
mutex_unlock(&devices_mutex);
@@ -135,18 +138,6 @@ static void bebob_free(struct snd_bebob *bebob)
snd_bebob_stream_destroy_duplex(bebob);
}
-/*
- * 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
-bebob_card_free(struct snd_card *card)
-{
- bebob_free(card->private_data);
-}
-
static const struct snd_bebob_spec *
get_saffire_spec(struct fw_unit *unit)
{
@@ -202,6 +193,9 @@ do_registration(struct work_struct *work)
set_bit(card_index, devices_used);
mutex_unlock(&devices_mutex);
+ bebob->card->private_free = bebob_card_free;
+ bebob->card->private_data = bebob;
+
err = name_device(bebob);
if (err < 0)
goto error;
@@ -241,17 +235,10 @@ do_registration(struct work_struct *work)
if (err < 0)
goto error;
- /*
- * After registered, bebob instance can be released corresponding to
- * releasing the sound card instance.
- */
- bebob->card->private_free = bebob_card_free;
- bebob->card->private_data = bebob;
bebob->registered = true;
return;
error:
- snd_bebob_stream_destroy_duplex(bebob);
snd_card_free(bebob->card);
dev_info(&bebob->unit->device,
"Sound card registration failed: %d\n", err);