aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/caiaq/device.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/caiaq/device.c')
-rw-r--r--sound/usb/caiaq/device.c248
1 files changed, 126 insertions, 122 deletions
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index e4d6dbb0342d..48b63ccc78c7 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -20,6 +20,7 @@
20*/ 20*/
21 21
22#include <linux/moduleparam.h> 22#include <linux/moduleparam.h>
23#include <linux/device.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
24#include <linux/module.h> 25#include <linux/module.h>
25#include <linux/init.h> 26#include <linux/init.h>
@@ -158,67 +159,68 @@ static struct usb_device_id snd_usb_id_table[] = {
158static void usb_ep1_command_reply_dispatch (struct urb* urb) 159static void usb_ep1_command_reply_dispatch (struct urb* urb)
159{ 160{
160 int ret; 161 int ret;
161 struct snd_usb_caiaqdev *dev = urb->context; 162 struct device *dev = &urb->dev->dev;
163 struct snd_usb_caiaqdev *cdev = urb->context;
162 unsigned char *buf = urb->transfer_buffer; 164 unsigned char *buf = urb->transfer_buffer;
163 165
164 if (urb->status || !dev) { 166 if (urb->status || !cdev) {
165 log("received EP1 urb->status = %i\n", urb->status); 167 dev_warn(dev, "received EP1 urb->status = %i\n", urb->status);
166 return; 168 return;
167 } 169 }
168 170
169 switch(buf[0]) { 171 switch(buf[0]) {
170 case EP1_CMD_GET_DEVICE_INFO: 172 case EP1_CMD_GET_DEVICE_INFO:
171 memcpy(&dev->spec, buf+1, sizeof(struct caiaq_device_spec)); 173 memcpy(&cdev->spec, buf+1, sizeof(struct caiaq_device_spec));
172 dev->spec.fw_version = le16_to_cpu(dev->spec.fw_version); 174 cdev->spec.fw_version = le16_to_cpu(cdev->spec.fw_version);
173 debug("device spec (firmware %d): audio: %d in, %d out, " 175 dev_dbg(dev, "device spec (firmware %d): audio: %d in, %d out, "
174 "MIDI: %d in, %d out, data alignment %d\n", 176 "MIDI: %d in, %d out, data alignment %d\n",
175 dev->spec.fw_version, 177 cdev->spec.fw_version,
176 dev->spec.num_analog_audio_in, 178 cdev->spec.num_analog_audio_in,
177 dev->spec.num_analog_audio_out, 179 cdev->spec.num_analog_audio_out,
178 dev->spec.num_midi_in, 180 cdev->spec.num_midi_in,
179 dev->spec.num_midi_out, 181 cdev->spec.num_midi_out,
180 dev->spec.data_alignment); 182 cdev->spec.data_alignment);
181 183
182 dev->spec_received++; 184 cdev->spec_received++;
183 wake_up(&dev->ep1_wait_queue); 185 wake_up(&cdev->ep1_wait_queue);
184 break; 186 break;
185 case EP1_CMD_AUDIO_PARAMS: 187 case EP1_CMD_AUDIO_PARAMS:
186 dev->audio_parm_answer = buf[1]; 188 cdev->audio_parm_answer = buf[1];
187 wake_up(&dev->ep1_wait_queue); 189 wake_up(&cdev->ep1_wait_queue);
188 break; 190 break;
189 case EP1_CMD_MIDI_READ: 191 case EP1_CMD_MIDI_READ:
190 snd_usb_caiaq_midi_handle_input(dev, buf[1], buf + 3, buf[2]); 192 snd_usb_caiaq_midi_handle_input(cdev, buf[1], buf + 3, buf[2]);
191 break; 193 break;
192 case EP1_CMD_READ_IO: 194 case EP1_CMD_READ_IO:
193 if (dev->chip.usb_id == 195 if (cdev->chip.usb_id ==
194 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)) { 196 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)) {
195 if (urb->actual_length > sizeof(dev->control_state)) 197 if (urb->actual_length > sizeof(cdev->control_state))
196 urb->actual_length = sizeof(dev->control_state); 198 urb->actual_length = sizeof(cdev->control_state);
197 memcpy(dev->control_state, buf + 1, urb->actual_length); 199 memcpy(cdev->control_state, buf + 1, urb->actual_length);
198 wake_up(&dev->ep1_wait_queue); 200 wake_up(&cdev->ep1_wait_queue);
199 break; 201 break;
200 } 202 }
201#ifdef CONFIG_SND_USB_CAIAQ_INPUT 203#ifdef CONFIG_SND_USB_CAIAQ_INPUT
202 case EP1_CMD_READ_ERP: 204 case EP1_CMD_READ_ERP:
203 case EP1_CMD_READ_ANALOG: 205 case EP1_CMD_READ_ANALOG:
204 snd_usb_caiaq_input_dispatch(dev, buf, urb->actual_length); 206 snd_usb_caiaq_input_dispatch(cdev, buf, urb->actual_length);
205#endif 207#endif
206 break; 208 break;
207 } 209 }
208 210
209 dev->ep1_in_urb.actual_length = 0; 211 cdev->ep1_in_urb.actual_length = 0;
210 ret = usb_submit_urb(&dev->ep1_in_urb, GFP_ATOMIC); 212 ret = usb_submit_urb(&cdev->ep1_in_urb, GFP_ATOMIC);
211 if (ret < 0) 213 if (ret < 0)
212 log("unable to submit urb. OOM!?\n"); 214 dev_err(dev, "unable to submit urb. OOM!?\n");
213} 215}
214 216
215int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev, 217int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev,
216 unsigned char command, 218 unsigned char command,
217 const unsigned char *buffer, 219 const unsigned char *buffer,
218 int len) 220 int len)
219{ 221{
220 int actual_len; 222 int actual_len;
221 struct usb_device *usb_dev = dev->chip.dev; 223 struct usb_device *usb_dev = cdev->chip.dev;
222 224
223 if (!usb_dev) 225 if (!usb_dev)
224 return -EIO; 226 return -EIO;
@@ -227,18 +229,19 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev,
227 len = EP1_BUFSIZE - 1; 229 len = EP1_BUFSIZE - 1;
228 230
229 if (buffer && len > 0) 231 if (buffer && len > 0)
230 memcpy(dev->ep1_out_buf+1, buffer, len); 232 memcpy(cdev->ep1_out_buf+1, buffer, len);
231 233
232 dev->ep1_out_buf[0] = command; 234 cdev->ep1_out_buf[0] = command;
233 return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1), 235 return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1),
234 dev->ep1_out_buf, len+1, &actual_len, 200); 236 cdev->ep1_out_buf, len+1, &actual_len, 200);
235} 237}
236 238
237int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, 239int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev,
238 int rate, int depth, int bpp) 240 int rate, int depth, int bpp)
239{ 241{
240 int ret; 242 int ret;
241 char tmp[5]; 243 char tmp[5];
244 struct device *dev = caiaqdev_to_dev(cdev);
242 245
243 switch (rate) { 246 switch (rate) {
244 case 44100: tmp[0] = SAMPLERATE_44100; break; 247 case 44100: tmp[0] = SAMPLERATE_44100; break;
@@ -259,49 +262,50 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
259 tmp[3] = bpp >> 8; 262 tmp[3] = bpp >> 8;
260 tmp[4] = 1; /* packets per microframe */ 263 tmp[4] = 1; /* packets per microframe */
261 264
262 debug("setting audio params: %d Hz, %d bits, %d bpp\n", 265 dev_dbg(dev, "setting audio params: %d Hz, %d bits, %d bpp\n",
263 rate, depth, bpp); 266 rate, depth, bpp);
264 267
265 dev->audio_parm_answer = -1; 268 cdev->audio_parm_answer = -1;
266 ret = snd_usb_caiaq_send_command(dev, EP1_CMD_AUDIO_PARAMS, 269 ret = snd_usb_caiaq_send_command(cdev, EP1_CMD_AUDIO_PARAMS,
267 tmp, sizeof(tmp)); 270 tmp, sizeof(tmp));
268 271
269 if (ret) 272 if (ret)
270 return ret; 273 return ret;
271 274
272 if (!wait_event_timeout(dev->ep1_wait_queue, 275 if (!wait_event_timeout(cdev->ep1_wait_queue,
273 dev->audio_parm_answer >= 0, HZ)) 276 cdev->audio_parm_answer >= 0, HZ))
274 return -EPIPE; 277 return -EPIPE;
275 278
276 if (dev->audio_parm_answer != 1) 279 if (cdev->audio_parm_answer != 1)
277 debug("unable to set the device's audio params\n"); 280 dev_dbg(dev, "unable to set the device's audio params\n");
278 else 281 else
279 dev->bpp = bpp; 282 cdev->bpp = bpp;
280 283
281 return dev->audio_parm_answer == 1 ? 0 : -EINVAL; 284 return cdev->audio_parm_answer == 1 ? 0 : -EINVAL;
282} 285}
283 286
284int snd_usb_caiaq_set_auto_msg(struct snd_usb_caiaqdev *dev, 287int snd_usb_caiaq_set_auto_msg(struct snd_usb_caiaqdev *cdev,
285 int digital, int analog, int erp) 288 int digital, int analog, int erp)
286{ 289{
287 char tmp[3] = { digital, analog, erp }; 290 char tmp[3] = { digital, analog, erp };
288 return snd_usb_caiaq_send_command(dev, EP1_CMD_AUTO_MSG, 291 return snd_usb_caiaq_send_command(cdev, EP1_CMD_AUTO_MSG,
289 tmp, sizeof(tmp)); 292 tmp, sizeof(tmp));
290} 293}
291 294
292static void setup_card(struct snd_usb_caiaqdev *dev) 295static void setup_card(struct snd_usb_caiaqdev *cdev)
293{ 296{
294 int ret; 297 int ret;
295 char val[4]; 298 char val[4];
299 struct device *dev = caiaqdev_to_dev(cdev);
296 300
297 /* device-specific startup specials */ 301 /* device-specific startup specials */
298 switch (dev->chip.usb_id) { 302 switch (cdev->chip.usb_id) {
299 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): 303 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
300 /* RigKontrol2 - display centered dash ('-') */ 304 /* RigKontrol2 - display centered dash ('-') */
301 val[0] = 0x00; 305 val[0] = 0x00;
302 val[1] = 0x00; 306 val[1] = 0x00;
303 val[2] = 0x01; 307 val[2] = 0x01;
304 snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 3); 308 snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 3);
305 break; 309 break;
306 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): 310 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
307 /* RigKontrol2 - display two centered dashes ('--') */ 311 /* RigKontrol2 - display two centered dashes ('--') */
@@ -309,69 +313,69 @@ static void setup_card(struct snd_usb_caiaqdev *dev)
309 val[1] = 0x40; 313 val[1] = 0x40;
310 val[2] = 0x40; 314 val[2] = 0x40;
311 val[3] = 0x00; 315 val[3] = 0x00;
312 snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 4); 316 snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 4);
313 break; 317 break;
314 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): 318 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
315 /* Audio Kontrol 1 - make USB-LED stop blinking */ 319 /* Audio Kontrol 1 - make USB-LED stop blinking */
316 val[0] = 0x00; 320 val[0] = 0x00;
317 snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 1); 321 snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 1);
318 break; 322 break;
319 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): 323 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
320 /* Audio 8 DJ - trigger read of current settings */ 324 /* Audio 8 DJ - trigger read of current settings */
321 dev->control_state[0] = 0xff; 325 cdev->control_state[0] = 0xff;
322 snd_usb_caiaq_set_auto_msg(dev, 1, 0, 0); 326 snd_usb_caiaq_set_auto_msg(cdev, 1, 0, 0);
323 snd_usb_caiaq_send_command(dev, EP1_CMD_READ_IO, NULL, 0); 327 snd_usb_caiaq_send_command(cdev, EP1_CMD_READ_IO, NULL, 0);
324 328
325 if (!wait_event_timeout(dev->ep1_wait_queue, 329 if (!wait_event_timeout(cdev->ep1_wait_queue,
326 dev->control_state[0] != 0xff, HZ)) 330 cdev->control_state[0] != 0xff, HZ))
327 return; 331 return;
328 332
329 /* fix up some defaults */ 333 /* fix up some defaults */
330 if ((dev->control_state[1] != 2) || 334 if ((cdev->control_state[1] != 2) ||
331 (dev->control_state[2] != 3) || 335 (cdev->control_state[2] != 3) ||
332 (dev->control_state[4] != 2)) { 336 (cdev->control_state[4] != 2)) {
333 dev->control_state[1] = 2; 337 cdev->control_state[1] = 2;
334 dev->control_state[2] = 3; 338 cdev->control_state[2] = 3;
335 dev->control_state[4] = 2; 339 cdev->control_state[4] = 2;
336 snd_usb_caiaq_send_command(dev, 340 snd_usb_caiaq_send_command(cdev,
337 EP1_CMD_WRITE_IO, dev->control_state, 6); 341 EP1_CMD_WRITE_IO, cdev->control_state, 6);
338 } 342 }
339 343
340 break; 344 break;
341 } 345 }
342 346
343 if (dev->spec.num_analog_audio_out + 347 if (cdev->spec.num_analog_audio_out +
344 dev->spec.num_analog_audio_in + 348 cdev->spec.num_analog_audio_in +
345 dev->spec.num_digital_audio_out + 349 cdev->spec.num_digital_audio_out +
346 dev->spec.num_digital_audio_in > 0) { 350 cdev->spec.num_digital_audio_in > 0) {
347 ret = snd_usb_caiaq_audio_init(dev); 351 ret = snd_usb_caiaq_audio_init(cdev);
348 if (ret < 0) 352 if (ret < 0)
349 log("Unable to set up audio system (ret=%d)\n", ret); 353 dev_err(dev, "Unable to set up audio system (ret=%d)\n", ret);
350 } 354 }
351 355
352 if (dev->spec.num_midi_in + 356 if (cdev->spec.num_midi_in +
353 dev->spec.num_midi_out > 0) { 357 cdev->spec.num_midi_out > 0) {
354 ret = snd_usb_caiaq_midi_init(dev); 358 ret = snd_usb_caiaq_midi_init(cdev);
355 if (ret < 0) 359 if (ret < 0)
356 log("Unable to set up MIDI system (ret=%d)\n", ret); 360 dev_err(dev, "Unable to set up MIDI system (ret=%d)\n", ret);
357 } 361 }
358 362
359#ifdef CONFIG_SND_USB_CAIAQ_INPUT 363#ifdef CONFIG_SND_USB_CAIAQ_INPUT
360 ret = snd_usb_caiaq_input_init(dev); 364 ret = snd_usb_caiaq_input_init(cdev);
361 if (ret < 0) 365 if (ret < 0)
362 log("Unable to set up input system (ret=%d)\n", ret); 366 dev_err(dev, "Unable to set up input system (ret=%d)\n", ret);
363#endif 367#endif
364 368
365 /* finally, register the card and all its sub-instances */ 369 /* finally, register the card and all its sub-instances */
366 ret = snd_card_register(dev->chip.card); 370 ret = snd_card_register(cdev->chip.card);
367 if (ret < 0) { 371 if (ret < 0) {
368 log("snd_card_register() returned %d\n", ret); 372 dev_err(dev, "snd_card_register() returned %d\n", ret);
369 snd_card_free(dev->chip.card); 373 snd_card_free(cdev->chip.card);
370 } 374 }
371 375
372 ret = snd_usb_caiaq_control_init(dev); 376 ret = snd_usb_caiaq_control_init(cdev);
373 if (ret < 0) 377 if (ret < 0)
374 log("Unable to set up control system (ret=%d)\n", ret); 378 dev_err(dev, "Unable to set up control system (ret=%d)\n", ret);
375} 379}
376 380
377static int create_card(struct usb_device *usb_dev, 381static int create_card(struct usb_device *usb_dev,
@@ -381,7 +385,7 @@ static int create_card(struct usb_device *usb_dev,
381 int devnum; 385 int devnum;
382 int err; 386 int err;
383 struct snd_card *card; 387 struct snd_card *card;
384 struct snd_usb_caiaqdev *dev; 388 struct snd_usb_caiaqdev *cdev;
385 389
386 for (devnum = 0; devnum < SNDRV_CARDS; devnum++) 390 for (devnum = 0; devnum < SNDRV_CARDS; devnum++)
387 if (enable[devnum] && !snd_card_used[devnum]) 391 if (enable[devnum] && !snd_card_used[devnum])
@@ -395,65 +399,66 @@ static int create_card(struct usb_device *usb_dev,
395 if (err < 0) 399 if (err < 0)
396 return err; 400 return err;
397 401
398 dev = caiaqdev(card); 402 cdev = caiaqdev(card);
399 dev->chip.dev = usb_dev; 403 cdev->chip.dev = usb_dev;
400 dev->chip.card = card; 404 cdev->chip.card = card;
401 dev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor), 405 cdev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor),
402 le16_to_cpu(usb_dev->descriptor.idProduct)); 406 le16_to_cpu(usb_dev->descriptor.idProduct));
403 spin_lock_init(&dev->spinlock); 407 spin_lock_init(&cdev->spinlock);
404 snd_card_set_dev(card, &intf->dev); 408 snd_card_set_dev(card, &intf->dev);
405 409
406 *cardp = card; 410 *cardp = card;
407 return 0; 411 return 0;
408} 412}
409 413
410static int init_card(struct snd_usb_caiaqdev *dev) 414static int init_card(struct snd_usb_caiaqdev *cdev)
411{ 415{
412 char *c, usbpath[32]; 416 char *c, usbpath[32];
413 struct usb_device *usb_dev = dev->chip.dev; 417 struct usb_device *usb_dev = cdev->chip.dev;
414 struct snd_card *card = dev->chip.card; 418 struct snd_card *card = cdev->chip.card;
419 struct device *dev = caiaqdev_to_dev(cdev);
415 int err, len; 420 int err, len;
416 421
417 if (usb_set_interface(usb_dev, 0, 1) != 0) { 422 if (usb_set_interface(usb_dev, 0, 1) != 0) {
418 log("can't set alt interface.\n"); 423 dev_err(dev, "can't set alt interface.\n");
419 return -EIO; 424 return -EIO;
420 } 425 }
421 426
422 usb_init_urb(&dev->ep1_in_urb); 427 usb_init_urb(&cdev->ep1_in_urb);
423 usb_init_urb(&dev->midi_out_urb); 428 usb_init_urb(&cdev->midi_out_urb);
424 429
425 usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev, 430 usb_fill_bulk_urb(&cdev->ep1_in_urb, usb_dev,
426 usb_rcvbulkpipe(usb_dev, 0x1), 431 usb_rcvbulkpipe(usb_dev, 0x1),
427 dev->ep1_in_buf, EP1_BUFSIZE, 432 cdev->ep1_in_buf, EP1_BUFSIZE,
428 usb_ep1_command_reply_dispatch, dev); 433 usb_ep1_command_reply_dispatch, cdev);
429 434
430 usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev, 435 usb_fill_bulk_urb(&cdev->midi_out_urb, usb_dev,
431 usb_sndbulkpipe(usb_dev, 0x1), 436 usb_sndbulkpipe(usb_dev, 0x1),
432 dev->midi_out_buf, EP1_BUFSIZE, 437 cdev->midi_out_buf, EP1_BUFSIZE,
433 snd_usb_caiaq_midi_output_done, dev); 438 snd_usb_caiaq_midi_output_done, cdev);
434 439
435 init_waitqueue_head(&dev->ep1_wait_queue); 440 init_waitqueue_head(&cdev->ep1_wait_queue);
436 init_waitqueue_head(&dev->prepare_wait_queue); 441 init_waitqueue_head(&cdev->prepare_wait_queue);
437 442
438 if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0) 443 if (usb_submit_urb(&cdev->ep1_in_urb, GFP_KERNEL) != 0)
439 return -EIO; 444 return -EIO;
440 445
441 err = snd_usb_caiaq_send_command(dev, EP1_CMD_GET_DEVICE_INFO, NULL, 0); 446 err = snd_usb_caiaq_send_command(cdev, EP1_CMD_GET_DEVICE_INFO, NULL, 0);
442 if (err) 447 if (err)
443 return err; 448 return err;
444 449
445 if (!wait_event_timeout(dev->ep1_wait_queue, dev->spec_received, HZ)) 450 if (!wait_event_timeout(cdev->ep1_wait_queue, cdev->spec_received, HZ))
446 return -ENODEV; 451 return -ENODEV;
447 452
448 usb_string(usb_dev, usb_dev->descriptor.iManufacturer, 453 usb_string(usb_dev, usb_dev->descriptor.iManufacturer,
449 dev->vendor_name, CAIAQ_USB_STR_LEN); 454 cdev->vendor_name, CAIAQ_USB_STR_LEN);
450 455
451 usb_string(usb_dev, usb_dev->descriptor.iProduct, 456 usb_string(usb_dev, usb_dev->descriptor.iProduct,
452 dev->product_name, CAIAQ_USB_STR_LEN); 457 cdev->product_name, CAIAQ_USB_STR_LEN);
453 458
454 strlcpy(card->driver, MODNAME, sizeof(card->driver)); 459 strlcpy(card->driver, MODNAME, sizeof(card->driver));
455 strlcpy(card->shortname, dev->product_name, sizeof(card->shortname)); 460 strlcpy(card->shortname, cdev->product_name, sizeof(card->shortname));
456 strlcpy(card->mixername, dev->product_name, sizeof(card->mixername)); 461 strlcpy(card->mixername, cdev->product_name, sizeof(card->mixername));
457 462
458 /* if the id was not passed as module option, fill it with a shortened 463 /* if the id was not passed as module option, fill it with a shortened
459 * version of the product string which does not contain any 464 * version of the product string which does not contain any
@@ -473,11 +478,10 @@ static int init_card(struct snd_usb_caiaqdev *dev)
473 } 478 }
474 479
475 usb_make_path(usb_dev, usbpath, sizeof(usbpath)); 480 usb_make_path(usb_dev, usbpath, sizeof(usbpath));
476 snprintf(card->longname, sizeof(card->longname), 481 snprintf(card->longname, sizeof(card->longname), "%s %s (%s)",
477 "%s %s (%s)", 482 cdev->vendor_name, cdev->product_name, usbpath);
478 dev->vendor_name, dev->product_name, usbpath);
479 483
480 setup_card(dev); 484 setup_card(cdev);
481 return 0; 485 return 0;
482} 486}
483 487
@@ -486,9 +490,9 @@ static int snd_probe(struct usb_interface *intf,
486{ 490{
487 int ret; 491 int ret;
488 struct snd_card *card = NULL; 492 struct snd_card *card = NULL;
489 struct usb_device *device = interface_to_usbdev(intf); 493 struct usb_device *usb_dev = interface_to_usbdev(intf);
490 494
491 ret = create_card(device, intf, &card); 495 ret = create_card(usb_dev, intf, &card);
492 496
493 if (ret < 0) 497 if (ret < 0)
494 return ret; 498 return ret;
@@ -496,7 +500,7 @@ static int snd_probe(struct usb_interface *intf,
496 usb_set_intfdata(intf, card); 500 usb_set_intfdata(intf, card);
497 ret = init_card(caiaqdev(card)); 501 ret = init_card(caiaqdev(card));
498 if (ret < 0) { 502 if (ret < 0) {
499 log("unable to init card! (ret=%d)\n", ret); 503 dev_err(&usb_dev->dev, "unable to init card! (ret=%d)\n", ret);
500 snd_card_free(card); 504 snd_card_free(card);
501 return ret; 505 return ret;
502 } 506 }
@@ -506,24 +510,25 @@ static int snd_probe(struct usb_interface *intf,
506 510
507static void snd_disconnect(struct usb_interface *intf) 511static void snd_disconnect(struct usb_interface *intf)
508{ 512{
509 struct snd_usb_caiaqdev *dev;
510 struct snd_card *card = usb_get_intfdata(intf); 513 struct snd_card *card = usb_get_intfdata(intf);
511 514 struct device *dev = intf->usb_dev;
512 debug("%s(%p)\n", __func__, intf); 515 struct snd_usb_caiaqdev *cdev;
513 516
514 if (!card) 517 if (!card)
515 return; 518 return;
516 519
517 dev = caiaqdev(card); 520 cdev = caiaqdev(card);
521 dev_dbg(dev, "%s(%p)\n", __func__, intf);
522
518 snd_card_disconnect(card); 523 snd_card_disconnect(card);
519 524
520#ifdef CONFIG_SND_USB_CAIAQ_INPUT 525#ifdef CONFIG_SND_USB_CAIAQ_INPUT
521 snd_usb_caiaq_input_free(dev); 526 snd_usb_caiaq_input_free(cdev);
522#endif 527#endif
523 snd_usb_caiaq_audio_free(dev); 528 snd_usb_caiaq_audio_free(cdev);
524 529
525 usb_kill_urb(&dev->ep1_in_urb); 530 usb_kill_urb(&cdev->ep1_in_urb);
526 usb_kill_urb(&dev->midi_out_urb); 531 usb_kill_urb(&cdev->midi_out_urb);
527 532
528 snd_card_free(card); 533 snd_card_free(card);
529 usb_reset_device(interface_to_usbdev(intf)); 534 usb_reset_device(interface_to_usbdev(intf));
@@ -539,4 +544,3 @@ static struct usb_driver snd_usb_driver = {
539}; 544};
540 545
541module_usb_driver(snd_usb_driver); 546module_usb_driver(snd_usb_driver);
542