hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/sound/firewire/digi00x/digi00x.c
....@@ -1,9 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * digi00x.c - a part of driver for Digidesign Digi 002/003 family
34 *
45 * Copyright (c) 2014-2015 Takashi Sakamoto
5
- *
6
- * Licensed under the terms of the GNU General Public License, version 2.
76 */
87
98 #include "digi00x.h"
....@@ -42,20 +41,12 @@
4241 return 0;
4342 }
4443
45
-static void dg00x_free(struct snd_dg00x *dg00x)
46
-{
47
- snd_dg00x_stream_destroy_duplex(dg00x);
48
- snd_dg00x_transaction_unregister(dg00x);
49
-
50
- fw_unit_put(dg00x->unit);
51
-
52
- mutex_destroy(&dg00x->mutex);
53
- kfree(dg00x);
54
-}
55
-
5644 static void dg00x_card_free(struct snd_card *card)
5745 {
58
- dg00x_free(card->private_data);
46
+ struct snd_dg00x *dg00x = card->private_data;
47
+
48
+ snd_dg00x_stream_destroy_duplex(dg00x);
49
+ snd_dg00x_transaction_unregister(dg00x);
5950 }
6051
6152 static void do_registration(struct work_struct *work)
....@@ -71,6 +62,8 @@
7162 &dg00x->card);
7263 if (err < 0)
7364 return;
65
+ dg00x->card->private_free = dg00x_card_free;
66
+ dg00x->card->private_data = dg00x;
7467
7568 err = name_card(dg00x);
7669 if (err < 0)
....@@ -102,14 +95,10 @@
10295 if (err < 0)
10396 goto error;
10497
105
- dg00x->card->private_free = dg00x_card_free;
106
- dg00x->card->private_data = dg00x;
10798 dg00x->registered = true;
10899
109100 return;
110101 error:
111
- snd_dg00x_transaction_unregister(dg00x);
112
- snd_dg00x_stream_destroy_duplex(dg00x);
113102 snd_card_free(dg00x->card);
114103 dev_info(&dg00x->unit->device,
115104 "Sound card registration failed: %d\n", err);
....@@ -121,8 +110,9 @@
121110 struct snd_dg00x *dg00x;
122111
123112 /* Allocate this independent of sound card instance. */
124
- dg00x = kzalloc(sizeof(struct snd_dg00x), GFP_KERNEL);
125
- if (dg00x == NULL)
113
+ dg00x = devm_kzalloc(&unit->device, sizeof(struct snd_dg00x),
114
+ GFP_KERNEL);
115
+ if (!dg00x)
126116 return -ENOMEM;
127117
128118 dg00x->unit = fw_unit_get(unit);
....@@ -174,12 +164,12 @@
174164 cancel_delayed_work_sync(&dg00x->dwork);
175165
176166 if (dg00x->registered) {
177
- /* No need to wait for releasing card object in this context. */
178
- snd_card_free_when_closed(dg00x->card);
179
- } else {
180
- /* Don't forget this case. */
181
- dg00x_free(dg00x);
167
+ // Block till all of ALSA character devices are released.
168
+ snd_card_free(dg00x->card);
182169 }
170
+
171
+ mutex_destroy(&dg00x->mutex);
172
+ fw_unit_put(dg00x->unit);
183173 }
184174
185175 static const struct ieee1394_device_id snd_dg00x_id_table[] = {
....@@ -207,7 +197,7 @@
207197 static struct fw_driver dg00x_driver = {
208198 .driver = {
209199 .owner = THIS_MODULE,
210
- .name = "snd-firewire-digi00x",
200
+ .name = KBUILD_MODNAME,
211201 .bus = &fw_bus_type,
212202 },
213203 .probe = snd_dg00x_probe,