diff options
author | Takashi Iwai <tiwai@alsa3.local> | 2008-12-28 10:55:08 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-01-12 09:21:55 -0500 |
commit | 51721f70acaca5aa056b07c5cbe58e62662c068c (patch) | |
tree | d713f2f2347b0f3779bffc78ae502312e235d8a4 /sound/usb/usx2y/us122l.c | |
parent | 3e7fb9f7ec00fd7cefd0d8e83df0cff86ce12515 (diff) |
ALSA: Return proper error code at probe in sound/usb/*
Some drivers in soudn/usb/* don't handle the error code properly
from snd_card_create(). This patch fixes these places.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/usx2y/us122l.c')
-rw-r--r-- | sound/usb/usx2y/us122l.c | 51 |
1 files changed, 31 insertions, 20 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 | ||
481 | static struct snd_card *usx2y_create_card(struct usb_device *device) | 481 | static 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 | ||
517 | static void *us122l_usb_probe(struct usb_interface *intf, | 518 | static 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 | ||
536 | static int snd_us122l_probe(struct usb_interface *intf, | 546 | static 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 | ||
556 | static void snd_us122l_disconnect(struct usb_interface *intf) | 567 | static void snd_us122l_disconnect(struct usb_interface *intf) |