aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/usx2y/us122l.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/usx2y/us122l.c')
-rw-r--r--sound/usb/usx2y/us122l.c59
1 files changed, 36 insertions, 23 deletions
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index 73e59f4403a4..98276aafefe6 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -478,19 +478,21 @@ 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;
485 int err;
486
485 for (dev = 0; dev < SNDRV_CARDS; ++dev) 487 for (dev = 0; dev < SNDRV_CARDS; ++dev)
486 if (enable[dev] && !snd_us122l_card_used[dev]) 488 if (enable[dev] && !snd_us122l_card_used[dev])
487 break; 489 break;
488 if (dev >= SNDRV_CARDS) 490 if (dev >= SNDRV_CARDS)
489 return NULL; 491 return -ENODEV;
490 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 492 err = snd_card_create(index[dev], id[dev], THIS_MODULE,
491 sizeof(struct us122l)); 493 sizeof(struct us122l), &card);
492 if (!card) 494 if (err < 0)
493 return NULL; 495 return err;
494 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; 496 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1;
495 497
496 US122L(card)->chip.dev = device; 498 US122L(card)->chip.dev = device;
@@ -509,46 +511,57 @@ static struct snd_card *usx2y_create_card(struct usb_device *device)
509 US122L(card)->chip.dev->devnum 511 US122L(card)->chip.dev->devnum
510 ); 512 );
511 snd_card_set_dev(card, &device->dev); 513 snd_card_set_dev(card, &device->dev);
512 return card; 514 *cardp = card;
515 return 0;
513} 516}
514 517
515static void *us122l_usb_probe(struct usb_interface *intf, 518static int us122l_usb_probe(struct usb_interface *intf,
516 const struct usb_device_id *device_id) 519 const struct usb_device_id *device_id,
520 struct snd_card **cardp)
517{ 521{
518 struct usb_device *device = interface_to_usbdev(intf); 522 struct usb_device *device = interface_to_usbdev(intf);
519 struct snd_card *card = usx2y_create_card(device); 523 struct snd_card *card;
524 int err;
520 525
521 if (!card) 526 err = usx2y_create_card(device, &card);
522 return NULL; 527 if (err < 0)
528 return err;
523 529
524 if (!us122l_create_card(card) || 530 if (!us122l_create_card(card)) {
525 snd_card_register(card) < 0) {
526 snd_card_free(card); 531 snd_card_free(card);
527 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;
528 } 539 }
529 540
530 usb_get_dev(device); 541 usb_get_dev(device);
531 return card; 542 *cardp = card;
543 return 0;
532} 544}
533 545
534static int snd_us122l_probe(struct usb_interface *intf, 546static int snd_us122l_probe(struct usb_interface *intf,
535 const struct usb_device_id *id) 547 const struct usb_device_id *id)
536{ 548{
537 struct snd_card *card; 549 struct snd_card *card;
550 int err;
551
538 snd_printdd(KERN_DEBUG"%p:%i\n", 552 snd_printdd(KERN_DEBUG"%p:%i\n",
539 intf, intf->cur_altsetting->desc.bInterfaceNumber); 553 intf, intf->cur_altsetting->desc.bInterfaceNumber);
540 if (intf->cur_altsetting->desc.bInterfaceNumber != 1) 554 if (intf->cur_altsetting->desc.bInterfaceNumber != 1)
541 return 0; 555 return 0;
542 556
543 card = us122l_usb_probe(usb_get_intf(intf), id); 557 err = us122l_usb_probe(usb_get_intf(intf), id, &card);
544 558 if (err < 0) {
545 if (card) { 559 usb_put_intf(intf);
546 usb_set_intfdata(intf, card); 560 return err;
547 return 0;
548 } 561 }
549 562
550 usb_put_intf(intf); 563 usb_set_intfdata(intf, card);
551 return -EIO; 564 return 0;
552} 565}
553 566
554static void snd_us122l_disconnect(struct usb_interface *intf) 567static void snd_us122l_disconnect(struct usb_interface *intf)