forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/firewire/tascam/tascam.c
....@@ -1,9 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * tascam.c - a part of driver for TASCAM FireWire series
34 *
45 * Copyright (c) 2015 Takashi Sakamoto
5
- *
6
- * Licensed under the terms of the GNU General Public License, version 2.
76 */
87
98 #include "tascam.h"
....@@ -85,20 +84,12 @@
8584 return 0;
8685 }
8786
88
-static void tscm_free(struct snd_tscm *tscm)
89
-{
90
- snd_tscm_transaction_unregister(tscm);
91
- snd_tscm_stream_destroy_duplex(tscm);
92
-
93
- fw_unit_put(tscm->unit);
94
-
95
- mutex_destroy(&tscm->mutex);
96
- kfree(tscm);
97
-}
98
-
9987 static void tscm_card_free(struct snd_card *card)
10088 {
101
- tscm_free(card->private_data);
89
+ struct snd_tscm *tscm = card->private_data;
90
+
91
+ snd_tscm_transaction_unregister(tscm);
92
+ snd_tscm_stream_destroy_duplex(tscm);
10293 }
10394
10495 static void do_registration(struct work_struct *work)
....@@ -110,6 +101,8 @@
110101 &tscm->card);
111102 if (err < 0)
112103 return;
104
+ tscm->card->private_free = tscm_card_free;
105
+ tscm->card->private_data = tscm;
113106
114107 err = identify_model(tscm);
115108 if (err < 0)
....@@ -141,18 +134,10 @@
141134 if (err < 0)
142135 goto error;
143136
144
- /*
145
- * After registered, tscm instance can be released corresponding to
146
- * releasing the sound card instance.
147
- */
148
- tscm->card->private_free = tscm_card_free;
149
- tscm->card->private_data = tscm;
150137 tscm->registered = true;
151138
152139 return;
153140 error:
154
- snd_tscm_transaction_unregister(tscm);
155
- snd_tscm_stream_destroy_duplex(tscm);
156141 snd_card_free(tscm->card);
157142 dev_info(&tscm->unit->device,
158143 "Sound card registration failed: %d\n", err);
....@@ -164,11 +149,9 @@
164149 struct snd_tscm *tscm;
165150
166151 /* Allocate this independent of sound card instance. */
167
- tscm = kzalloc(sizeof(struct snd_tscm), GFP_KERNEL);
168
- if (tscm == NULL)
152
+ tscm = devm_kzalloc(&unit->device, sizeof(struct snd_tscm), GFP_KERNEL);
153
+ if (!tscm)
169154 return -ENOMEM;
170
-
171
- /* initialize myself */
172155 tscm->unit = fw_unit_get(unit);
173156 dev_set_drvdata(&unit->device, tscm);
174157
....@@ -216,12 +199,12 @@
216199 cancel_delayed_work_sync(&tscm->dwork);
217200
218201 if (tscm->registered) {
219
- /* No need to wait for releasing card object in this context. */
220
- snd_card_free_when_closed(tscm->card);
221
- } else {
222
- /* Don't forget this case. */
223
- tscm_free(tscm);
202
+ // Block till all of ALSA character devices are released.
203
+ snd_card_free(tscm->card);
224204 }
205
+
206
+ mutex_destroy(&tscm->mutex);
207
+ fw_unit_put(tscm->unit);
225208 }
226209
227210 static const struct ieee1394_device_id snd_tscm_id_table[] = {
....@@ -259,7 +242,6 @@
259242 .specifier_id = 0x00022e,
260243 .version = 0x800004,
261244 },
262
- /* FE-08 requires reverse-engineering because it just has faders. */
263245 {}
264246 };
265247 MODULE_DEVICE_TABLE(ieee1394, snd_tscm_id_table);
....@@ -267,7 +249,7 @@
267249 static struct fw_driver tscm_driver = {
268250 .driver = {
269251 .owner = THIS_MODULE,
270
- .name = "snd-firewire-tascam",
252
+ .name = KBUILD_MODNAME,
271253 .bus = &fw_bus_type,
272254 },
273255 .probe = snd_tscm_probe,