aboutsummaryrefslogtreecommitdiffstats
path: root/sound/firewire/bebob/bebob.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/firewire/bebob/bebob.c')
-rw-r--r--sound/firewire/bebob/bebob.c58
1 files changed, 16 insertions, 42 deletions
diff --git a/sound/firewire/bebob/bebob.c b/sound/firewire/bebob/bebob.c
index 93676354f87f..672d13488454 100644
--- a/sound/firewire/bebob/bebob.c
+++ b/sound/firewire/bebob/bebob.c
@@ -126,23 +126,6 @@ end:
return err;
}
-static void bebob_free(struct snd_bebob *bebob)
-{
- snd_bebob_stream_destroy_duplex(bebob);
- fw_unit_put(bebob->unit);
-
- kfree(bebob->maudio_special_quirk);
-
- mutex_destroy(&bebob->mutex);
- kfree(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)
{
@@ -152,7 +135,7 @@ bebob_card_free(struct snd_card *card)
clear_bit(bebob->card_index, devices_used);
mutex_unlock(&devices_mutex);
- bebob_free(card->private_data);
+ snd_bebob_stream_destroy_duplex(bebob);
}
static const struct snd_bebob_spec *
@@ -192,7 +175,6 @@ do_registration(struct work_struct *work)
return;
mutex_lock(&devices_mutex);
-
for (card_index = 0; card_index < SNDRV_CARDS; card_index++) {
if (!test_bit(card_index, devices_used) && enable[card_index])
break;
@@ -208,6 +190,11 @@ do_registration(struct work_struct *work)
mutex_unlock(&devices_mutex);
return;
}
+ 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)
@@ -248,23 +235,10 @@ do_registration(struct work_struct *work)
if (err < 0)
goto error;
- set_bit(card_index, devices_used);
- mutex_unlock(&devices_mutex);
-
- /*
- * 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:
- mutex_unlock(&devices_mutex);
- snd_bebob_stream_destroy_duplex(bebob);
- kfree(bebob->maudio_special_quirk);
- bebob->maudio_special_quirk = NULL;
snd_card_free(bebob->card);
dev_info(&bebob->unit->device,
"Sound card registration failed: %d\n", err);
@@ -295,15 +269,15 @@ bebob_probe(struct fw_unit *unit, const struct ieee1394_device_id *entry)
}
/* Allocate this independent of sound card instance. */
- bebob = kzalloc(sizeof(struct snd_bebob), GFP_KERNEL);
- if (bebob == NULL)
+ bebob = devm_kzalloc(&unit->device, sizeof(struct snd_bebob),
+ GFP_KERNEL);
+ if (!bebob)
return -ENOMEM;
-
bebob->unit = fw_unit_get(unit);
- bebob->entry = entry;
- bebob->spec = spec;
dev_set_drvdata(&unit->device, bebob);
+ bebob->entry = entry;
+ bebob->spec = spec;
mutex_init(&bebob->mutex);
spin_lock_init(&bebob->lock);
init_waitqueue_head(&bebob->hwdep_wait);
@@ -379,12 +353,12 @@ static void bebob_remove(struct fw_unit *unit)
cancel_delayed_work_sync(&bebob->dwork);
if (bebob->registered) {
- /* No need to wait for releasing card object in this context. */
- snd_card_free_when_closed(bebob->card);
- } else {
- /* Don't forget this case. */
- bebob_free(bebob);
+ // Block till all of ALSA character devices are released.
+ snd_card_free(bebob->card);
}
+
+ mutex_destroy(&bebob->mutex);
+ fw_unit_put(bebob->unit);
}
static const struct snd_bebob_rate_spec normal_rate_spec = {