oxfw.c (edfbeecd92b0c4a648ed96a7e255bfc9a1bc4642) oxfw.c (61ccc6f6b27c03bb32ca38a3c580d49ce1612d43)
1/*
2 * oxfw.c - a part of driver for OXFW970/971 based devices
3 *
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 * Licensed under the terms of the GNU General Public License, version 2.
6 */
7
8#include "oxfw.h"

--- 101 unchanged lines hidden (view full) ---

110 fw_dev->config_rom[3], fw_dev->config_rom[4],
111 dev_name(&oxfw->unit->device), 100 << fw_dev->max_speed);
112end:
113 return err;
114}
115
116static void oxfw_free(struct snd_oxfw *oxfw)
117{
1/*
2 * oxfw.c - a part of driver for OXFW970/971 based devices
3 *
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 * Licensed under the terms of the GNU General Public License, version 2.
6 */
7
8#include "oxfw.h"

--- 101 unchanged lines hidden (view full) ---

110 fw_dev->config_rom[3], fw_dev->config_rom[4],
111 dev_name(&oxfw->unit->device), 100 << fw_dev->max_speed);
112end:
113 return err;
114}
115
116static void oxfw_free(struct snd_oxfw *oxfw)
117{
118 unsigned int i;
119
120 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);
121 if (oxfw->has_output)
122 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);
123
118 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);
119 if (oxfw->has_output)
120 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);
121
124 fw_unit_put(oxfw->unit);
125
126 for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
127 kfree(oxfw->tx_stream_formats[i]);
128 kfree(oxfw->rx_stream_formats[i]);
129 }
130
131 kfree(oxfw->spec);
132 mutex_destroy(&oxfw->mutex);
122 mutex_destroy(&oxfw->mutex);
133 kfree(oxfw);
123 fw_unit_put(oxfw->unit);
134}
135
136/*
137 * This module releases the FireWire unit data after all ALSA character devices
138 * are released by applications. This is for releasing stream data or finishing
139 * transactions safely. Thus at returning from .remove(), this module still keep
140 * references for the unit.
141 */

--- 61 unchanged lines hidden (view full) ---

203 oxfw->wrong_dbs = true;
204
205 return 0;
206}
207
208static void do_registration(struct work_struct *work)
209{
210 struct snd_oxfw *oxfw = container_of(work, struct snd_oxfw, dwork.work);
124}
125
126/*
127 * This module releases the FireWire unit data after all ALSA character devices
128 * are released by applications. This is for releasing stream data or finishing
129 * transactions safely. Thus at returning from .remove(), this module still keep
130 * references for the unit.
131 */

--- 61 unchanged lines hidden (view full) ---

193 oxfw->wrong_dbs = true;
194
195 return 0;
196}
197
198static void do_registration(struct work_struct *work)
199{
200 struct snd_oxfw *oxfw = container_of(work, struct snd_oxfw, dwork.work);
211 int i;
212 int err;
213
214 if (oxfw->registered)
215 return;
216
217 err = snd_card_new(&oxfw->unit->device, -1, NULL, THIS_MODULE, 0,
218 &oxfw->card);
219 if (err < 0)

--- 46 unchanged lines hidden (view full) ---

266 oxfw->card->private_data = oxfw;
267 oxfw->registered = true;
268
269 return;
270error:
271 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);
272 if (oxfw->has_output)
273 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);
201 int err;
202
203 if (oxfw->registered)
204 return;
205
206 err = snd_card_new(&oxfw->unit->device, -1, NULL, THIS_MODULE, 0,
207 &oxfw->card);
208 if (err < 0)

--- 46 unchanged lines hidden (view full) ---

255 oxfw->card->private_data = oxfw;
256 oxfw->registered = true;
257
258 return;
259error:
260 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);
261 if (oxfw->has_output)
262 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);
274 for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; ++i) {
275 kfree(oxfw->tx_stream_formats[i]);
276 oxfw->tx_stream_formats[i] = NULL;
277 kfree(oxfw->rx_stream_formats[i]);
278 oxfw->rx_stream_formats[i] = NULL;
279 }
280 snd_card_free(oxfw->card);
263 snd_card_free(oxfw->card);
281 kfree(oxfw->spec);
282 oxfw->spec = NULL;
283 dev_info(&oxfw->unit->device,
284 "Sound card registration failed: %d\n", err);
285}
286
287static int oxfw_probe(struct fw_unit *unit,
288 const struct ieee1394_device_id *entry)
289{
290 struct snd_oxfw *oxfw;
291
292 if (entry->vendor_id == VENDOR_LOUD && !detect_loud_models(unit))
293 return -ENODEV;
294
295 /* Allocate this independent of sound card instance. */
264 dev_info(&oxfw->unit->device,
265 "Sound card registration failed: %d\n", err);
266}
267
268static int oxfw_probe(struct fw_unit *unit,
269 const struct ieee1394_device_id *entry)
270{
271 struct snd_oxfw *oxfw;
272
273 if (entry->vendor_id == VENDOR_LOUD && !detect_loud_models(unit))
274 return -ENODEV;
275
276 /* Allocate this independent of sound card instance. */
296 oxfw = kzalloc(sizeof(struct snd_oxfw), GFP_KERNEL);
297 if (oxfw == NULL)
277 oxfw = devm_kzalloc(&unit->device, sizeof(struct snd_oxfw), GFP_KERNEL);
278 if (!oxfw)
298 return -ENOMEM;
279 return -ENOMEM;
299
300 oxfw->entry = entry;
301 oxfw->unit = fw_unit_get(unit);
302 dev_set_drvdata(&unit->device, oxfw);
303
280 oxfw->unit = fw_unit_get(unit);
281 dev_set_drvdata(&unit->device, oxfw);
282
283 oxfw->entry = entry;
304 mutex_init(&oxfw->mutex);
305 spin_lock_init(&oxfw->lock);
306 init_waitqueue_head(&oxfw->hwdep_wait);
307
308 /* Allocate and register this sound card later. */
309 INIT_DEFERRABLE_WORK(&oxfw->dwork, do_registration);
310 snd_fw_schedule_registration(unit, &oxfw->dwork);
311

--- 30 unchanged lines hidden (view full) ---

342 /*
343 * Confirm to stop the work for registration before the sound card is
344 * going to be released. The work is not scheduled again because bus
345 * reset handler is not called anymore.
346 */
347 cancel_delayed_work_sync(&oxfw->dwork);
348
349 if (oxfw->registered) {
284 mutex_init(&oxfw->mutex);
285 spin_lock_init(&oxfw->lock);
286 init_waitqueue_head(&oxfw->hwdep_wait);
287
288 /* Allocate and register this sound card later. */
289 INIT_DEFERRABLE_WORK(&oxfw->dwork, do_registration);
290 snd_fw_schedule_registration(unit, &oxfw->dwork);
291

--- 30 unchanged lines hidden (view full) ---

322 /*
323 * Confirm to stop the work for registration before the sound card is
324 * going to be released. The work is not scheduled again because bus
325 * reset handler is not called anymore.
326 */
327 cancel_delayed_work_sync(&oxfw->dwork);
328
329 if (oxfw->registered) {
350 /* No need to wait for releasing card object in this context. */
351 snd_card_free_when_closed(oxfw->card);
330 // Block till all of ALSA character devices are released.
331 snd_card_free(oxfw->card);
352 } else {
353 /* Don't forget this case. */
354 oxfw_free(oxfw);
355 }
356}
357
358static const struct compat_info griffin_firewave = {
359 .driver_name = "FireWave",

--- 107 unchanged lines hidden ---
332 } else {
333 /* Don't forget this case. */
334 oxfw_free(oxfw);
335 }
336}
337
338static const struct compat_info griffin_firewave = {
339 .driver_name = "FireWave",

--- 107 unchanged lines hidden ---