summaryrefslogtreecommitdiff
path: root/sound/firewire/digi00x/digi00x.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/firewire/digi00x/digi00x.c')
-rw-r--r--sound/firewire/digi00x/digi00x.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/sound/firewire/digi00x/digi00x.c b/sound/firewire/digi00x/digi00x.c
index 1f5e1d23f31a..6c6ea149ef6b 100644
--- a/sound/firewire/digi00x/digi00x.c
+++ b/sound/firewire/digi00x/digi00x.c
@@ -41,19 +41,12 @@ static int name_card(struct snd_dg00x *dg00x)
return 0;
}
-static void dg00x_free(struct snd_dg00x *dg00x)
+static void dg00x_card_free(struct snd_card *card)
{
+ struct snd_dg00x *dg00x = card->private_data;
+
snd_dg00x_stream_destroy_duplex(dg00x);
snd_dg00x_transaction_unregister(dg00x);
-
- fw_unit_put(dg00x->unit);
-
- mutex_destroy(&dg00x->mutex);
-}
-
-static void dg00x_card_free(struct snd_card *card)
-{
- dg00x_free(card->private_data);
}
static void do_registration(struct work_struct *work)
@@ -69,6 +62,8 @@ static void do_registration(struct work_struct *work)
&dg00x->card);
if (err < 0)
return;
+ dg00x->card->private_free = dg00x_card_free;
+ dg00x->card->private_data = dg00x;
err = name_card(dg00x);
if (err < 0)
@@ -100,14 +95,10 @@ static void do_registration(struct work_struct *work)
if (err < 0)
goto error;
- dg00x->card->private_free = dg00x_card_free;
- dg00x->card->private_data = dg00x;
dg00x->registered = true;
return;
error:
- snd_dg00x_transaction_unregister(dg00x);
- snd_dg00x_stream_destroy_duplex(dg00x);
snd_card_free(dg00x->card);
dev_info(&dg00x->unit->device,
"Sound card registration failed: %d\n", err);
@@ -119,8 +110,9 @@ static int snd_dg00x_probe(struct fw_unit *unit,
struct snd_dg00x *dg00x;
/* Allocate this independent of sound card instance. */
- dg00x = kzalloc(sizeof(struct snd_dg00x), GFP_KERNEL);
- if (dg00x == NULL)
+ dg00x = devm_kzalloc(&unit->device, sizeof(struct snd_dg00x),
+ GFP_KERNEL);
+ if (!dg00x)
return -ENOMEM;
dg00x->unit = fw_unit_get(unit);
@@ -172,12 +164,12 @@ static void snd_dg00x_remove(struct fw_unit *unit)
cancel_delayed_work_sync(&dg00x->dwork);
if (dg00x->registered) {
- /* No need to wait for releasing card object in this context. */
- snd_card_free_when_closed(dg00x->card);
- } else {
- /* Don't forget this case. */
- dg00x_free(dg00x);
+ // Block till all of ALSA character devices are released.
+ snd_card_free(dg00x->card);
}
+
+ mutex_destroy(&dg00x->mutex);
+ fw_unit_put(dg00x->unit);
}
static const struct ieee1394_device_id snd_dg00x_id_table[] = {