.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * digi00x.c - a part of driver for Digidesign Digi 002/003 family |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2014-2015 Takashi Sakamoto |
---|
5 | | - * |
---|
6 | | - * Licensed under the terms of the GNU General Public License, version 2. |
---|
7 | 6 | */ |
---|
8 | 7 | |
---|
9 | 8 | #include "digi00x.h" |
---|
.. | .. |
---|
42 | 41 | return 0; |
---|
43 | 42 | } |
---|
44 | 43 | |
---|
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 | | - |
---|
56 | 44 | static void dg00x_card_free(struct snd_card *card) |
---|
57 | 45 | { |
---|
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); |
---|
59 | 50 | } |
---|
60 | 51 | |
---|
61 | 52 | static void do_registration(struct work_struct *work) |
---|
.. | .. |
---|
71 | 62 | &dg00x->card); |
---|
72 | 63 | if (err < 0) |
---|
73 | 64 | return; |
---|
| 65 | + dg00x->card->private_free = dg00x_card_free; |
---|
| 66 | + dg00x->card->private_data = dg00x; |
---|
74 | 67 | |
---|
75 | 68 | err = name_card(dg00x); |
---|
76 | 69 | if (err < 0) |
---|
.. | .. |
---|
102 | 95 | if (err < 0) |
---|
103 | 96 | goto error; |
---|
104 | 97 | |
---|
105 | | - dg00x->card->private_free = dg00x_card_free; |
---|
106 | | - dg00x->card->private_data = dg00x; |
---|
107 | 98 | dg00x->registered = true; |
---|
108 | 99 | |
---|
109 | 100 | return; |
---|
110 | 101 | error: |
---|
111 | | - snd_dg00x_transaction_unregister(dg00x); |
---|
112 | | - snd_dg00x_stream_destroy_duplex(dg00x); |
---|
113 | 102 | snd_card_free(dg00x->card); |
---|
114 | 103 | dev_info(&dg00x->unit->device, |
---|
115 | 104 | "Sound card registration failed: %d\n", err); |
---|
.. | .. |
---|
121 | 110 | struct snd_dg00x *dg00x; |
---|
122 | 111 | |
---|
123 | 112 | /* 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) |
---|
126 | 116 | return -ENOMEM; |
---|
127 | 117 | |
---|
128 | 118 | dg00x->unit = fw_unit_get(unit); |
---|
.. | .. |
---|
174 | 164 | cancel_delayed_work_sync(&dg00x->dwork); |
---|
175 | 165 | |
---|
176 | 166 | 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); |
---|
182 | 169 | } |
---|
| 170 | + |
---|
| 171 | + mutex_destroy(&dg00x->mutex); |
---|
| 172 | + fw_unit_put(dg00x->unit); |
---|
183 | 173 | } |
---|
184 | 174 | |
---|
185 | 175 | static const struct ieee1394_device_id snd_dg00x_id_table[] = { |
---|
.. | .. |
---|
207 | 197 | static struct fw_driver dg00x_driver = { |
---|
208 | 198 | .driver = { |
---|
209 | 199 | .owner = THIS_MODULE, |
---|
210 | | - .name = "snd-firewire-digi00x", |
---|
| 200 | + .name = KBUILD_MODNAME, |
---|
211 | 201 | .bus = &fw_bus_type, |
---|
212 | 202 | }, |
---|
213 | 203 | .probe = snd_dg00x_probe, |
---|