aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/usx2y
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/usx2y')
-rw-r--r--sound/usb/usx2y/us122l.c51
-rw-r--r--sound/usb/usx2y/usbusx2y.c45
2 files changed, 59 insertions, 37 deletions
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index b21bb475c0ff..98276aafefe6 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -478,7 +478,7 @@ static bool us122l_create_card(struct snd_card *card)
478 return true; 478 return true;
479} 479}
480 480
481static struct snd_card *usx2y_create_card(struct usb_device *device) 481static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
482{ 482{
483 int dev; 483 int dev;
484 struct snd_card *card; 484 struct snd_card *card;
@@ -488,11 +488,11 @@ static struct snd_card *usx2y_create_card(struct usb_device *device)
488 if (enable[dev] && !snd_us122l_card_used[dev]) 488 if (enable[dev] && !snd_us122l_card_used[dev])
489 break; 489 break;
490 if (dev >= SNDRV_CARDS) 490 if (dev >= SNDRV_CARDS)
491 return NULL; 491 return -ENODEV;
492 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 492 err = snd_card_create(index[dev], id[dev], THIS_MODULE,
493 sizeof(struct us122l), &card); 493 sizeof(struct us122l), &card);
494 if (err < 0) 494 if (err < 0)
495 return NULL; 495 return err;
496 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; 496 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1;
497 497
498 US122L(card)->chip.dev = device; 498 US122L(card)->chip.dev = device;
@@ -511,46 +511,57 @@ static struct snd_card *usx2y_create_card(struct usb_device *device)
511 US122L(card)->chip.dev->devnum 511 US122L(card)->chip.dev->devnum
512 ); 512 );
513 snd_card_set_dev(card, &device->dev); 513 snd_card_set_dev(card, &device->dev);
514 return card; 514 *cardp = card;
515 return 0;
515} 516}
516 517
517static void *us122l_usb_probe(struct usb_interface *intf, 518static int us122l_usb_probe(struct usb_interface *intf,
518 const struct usb_device_id *device_id) 519 const struct usb_device_id *device_id,
520 struct snd_card **cardp)
519{ 521{
520 struct usb_device *device = interface_to_usbdev(intf); 522 struct usb_device *device = interface_to_usbdev(intf);
521 struct snd_card *card = usx2y_create_card(device); 523 struct snd_card *card;
524 int err;
522 525
523 if (!card) 526 err = usx2y_create_card(device, &card);
524 return NULL; 527 if (err < 0)
528 return err;
525 529
526 if (!us122l_create_card(card) || 530 if (!us122l_create_card(card)) {
527 snd_card_register(card) < 0) {
528 snd_card_free(card); 531 snd_card_free(card);
529 return NULL; 532 return -EINVAL;
533 }
534
535 err = snd_card_register(card);
536 if (err < 0) {
537 snd_card_free(card);
538 return err;
530 } 539 }
531 540
532 usb_get_dev(device); 541 usb_get_dev(device);
533 return card; 542 *cardp = card;
543 return 0;
534} 544}
535 545
536static int snd_us122l_probe(struct usb_interface *intf, 546static int snd_us122l_probe(struct usb_interface *intf,
537 const struct usb_device_id *id) 547 const struct usb_device_id *id)
538{ 548{
539 struct snd_card *card; 549 struct snd_card *card;
550 int err;
551
540 snd_printdd(KERN_DEBUG"%p:%i\n", 552 snd_printdd(KERN_DEBUG"%p:%i\n",
541 intf, intf->cur_altsetting->desc.bInterfaceNumber); 553 intf, intf->cur_altsetting->desc.bInterfaceNumber);
542 if (intf->cur_altsetting->desc.bInterfaceNumber != 1) 554 if (intf->cur_altsetting->desc.bInterfaceNumber != 1)
543 return 0; 555 return 0;
544 556
545 card = us122l_usb_probe(usb_get_intf(intf), id); 557 err = us122l_usb_probe(usb_get_intf(intf), id, &card);
546 558 if (err < 0) {
547 if (card) { 559 usb_put_intf(intf);
548 usb_set_intfdata(intf, card); 560 return err;
549 return 0;
550 } 561 }
551 562
552 usb_put_intf(intf); 563 usb_set_intfdata(intf, card);
553 return -EIO; 564 return 0;
554} 565}
555 566
556static void snd_us122l_disconnect(struct usb_interface *intf) 567static void snd_us122l_disconnect(struct usb_interface *intf)
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c
index b848a1806385..af8b84954054 100644
--- a/sound/usb/usx2y/usbusx2y.c
+++ b/sound/usb/usx2y/usbusx2y.c
@@ -333,7 +333,7 @@ static struct usb_device_id snd_usX2Y_usb_id_table[] = {
333 { /* terminator */ } 333 { /* terminator */ }
334}; 334};
335 335
336static struct snd_card *usX2Y_create_card(struct usb_device *device) 336static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp)
337{ 337{
338 int dev; 338 int dev;
339 struct snd_card * card; 339 struct snd_card * card;
@@ -343,11 +343,11 @@ static struct snd_card *usX2Y_create_card(struct usb_device *device)
343 if (enable[dev] && !snd_usX2Y_card_used[dev]) 343 if (enable[dev] && !snd_usX2Y_card_used[dev])
344 break; 344 break;
345 if (dev >= SNDRV_CARDS) 345 if (dev >= SNDRV_CARDS)
346 return NULL; 346 return -ENODEV;
347 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 347 err = snd_card_create(index[dev], id[dev], THIS_MODULE,
348 sizeof(struct usX2Ydev), &card); 348 sizeof(struct usX2Ydev), &card);
349 if (err < 0) 349 if (err < 0)
350 return NULL; 350 return err;
351 snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1; 351 snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1;
352 card->private_free = snd_usX2Y_card_private_free; 352 card->private_free = snd_usX2Y_card_private_free;
353 usX2Y(card)->chip.dev = device; 353 usX2Y(card)->chip.dev = device;
@@ -365,26 +365,36 @@ static struct snd_card *usX2Y_create_card(struct usb_device *device)
365 usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum 365 usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum
366 ); 366 );
367 snd_card_set_dev(card, &device->dev); 367 snd_card_set_dev(card, &device->dev);
368 return card; 368 *cardp = card;
369 return 0;
369} 370}
370 371
371 372
372static void *usX2Y_usb_probe(struct usb_device *device, struct usb_interface *intf, const struct usb_device_id *device_id) 373static int usX2Y_usb_probe(struct usb_device *device,
374 struct usb_interface *intf,
375 const struct usb_device_id *device_id,
376 struct snd_card **cardp)
373{ 377{
374 int err; 378 int err;
375 struct snd_card * card; 379 struct snd_card * card;
380
381 *cardp = NULL;
376 if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 || 382 if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 ||
377 (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 && 383 (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 &&
378 le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 && 384 le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 &&
379 le16_to_cpu(device->descriptor.idProduct) != USB_ID_US428) || 385 le16_to_cpu(device->descriptor.idProduct) != USB_ID_US428))
380 !(card = usX2Y_create_card(device))) 386 return -EINVAL;
381 return NULL; 387
388 err = usX2Y_create_card(device, &card);
389 if (err < 0)
390 return err;
382 if ((err = usX2Y_hwdep_new(card, device)) < 0 || 391 if ((err = usX2Y_hwdep_new(card, device)) < 0 ||
383 (err = snd_card_register(card)) < 0) { 392 (err = snd_card_register(card)) < 0) {
384 snd_card_free(card); 393 snd_card_free(card);
385 return NULL; 394 return err;
386 } 395 }
387 return card; 396 *cardp = card;
397 return 0;
388} 398}
389 399
390/* 400/*
@@ -392,13 +402,14 @@ static void *usX2Y_usb_probe(struct usb_device *device, struct usb_interface *in
392 */ 402 */
393static int snd_usX2Y_probe(struct usb_interface *intf, const struct usb_device_id *id) 403static int snd_usX2Y_probe(struct usb_interface *intf, const struct usb_device_id *id)
394{ 404{
395 void *chip; 405 struct snd_card *card;
396 chip = usX2Y_usb_probe(interface_to_usbdev(intf), intf, id); 406 int err;
397 if (chip) { 407
398 usb_set_intfdata(intf, chip); 408 err = usX2Y_usb_probe(interface_to_usbdev(intf), intf, id, &card);
399 return 0; 409 if (err < 0)
400 } else 410 return err;
401 return -EIO; 411 dev_set_drvdata(&intf->dev, card);
412 return 0;
402} 413}
403 414
404static void snd_usX2Y_disconnect(struct usb_interface *intf) 415static void snd_usX2Y_disconnect(struct usb_interface *intf)