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 | |
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')
-rw-r--r-- | sound/usb/caiaq/caiaq-device.c | 15 | ||||
-rw-r--r-- | sound/usb/usx2y/us122l.c | 51 | ||||
-rw-r--r-- | sound/usb/usx2y/usbusx2y.c | 45 |
3 files changed, 67 insertions, 44 deletions
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c index 63a2c1d5779b..55a9075cb097 100644 --- a/sound/usb/caiaq/caiaq-device.c +++ b/sound/usb/caiaq/caiaq-device.c | |||
@@ -336,7 +336,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev) | |||
336 | log("Unable to set up control system (ret=%d)\n", ret); | 336 | log("Unable to set up control system (ret=%d)\n", ret); |
337 | } | 337 | } |
338 | 338 | ||
339 | static struct snd_card* create_card(struct usb_device* usb_dev) | 339 | static int create_card(struct usb_device* usb_dev, struct snd_card **cardp) |
340 | { | 340 | { |
341 | int devnum; | 341 | int devnum; |
342 | int err; | 342 | int err; |
@@ -348,12 +348,12 @@ static struct snd_card* create_card(struct usb_device* usb_dev) | |||
348 | break; | 348 | break; |
349 | 349 | ||
350 | if (devnum >= SNDRV_CARDS) | 350 | if (devnum >= SNDRV_CARDS) |
351 | return NULL; | 351 | return -ENODEV; |
352 | 352 | ||
353 | err = snd_card_create(index[devnum], id[devnum], THIS_MODULE, | 353 | err = snd_card_create(index[devnum], id[devnum], THIS_MODULE, |
354 | sizeof(struct snd_usb_caiaqdev), &card); | 354 | sizeof(struct snd_usb_caiaqdev), &card); |
355 | if (err < 0) | 355 | if (err < 0) |
356 | return NULL; | 356 | return err; |
357 | 357 | ||
358 | dev = caiaqdev(card); | 358 | dev = caiaqdev(card); |
359 | dev->chip.dev = usb_dev; | 359 | dev->chip.dev = usb_dev; |
@@ -363,7 +363,8 @@ static struct snd_card* create_card(struct usb_device* usb_dev) | |||
363 | spin_lock_init(&dev->spinlock); | 363 | spin_lock_init(&dev->spinlock); |
364 | snd_card_set_dev(card, &usb_dev->dev); | 364 | snd_card_set_dev(card, &usb_dev->dev); |
365 | 365 | ||
366 | return card; | 366 | *cardp = card; |
367 | return 0; | ||
367 | } | 368 | } |
368 | 369 | ||
369 | static int __devinit init_card(struct snd_usb_caiaqdev *dev) | 370 | static int __devinit init_card(struct snd_usb_caiaqdev *dev) |
@@ -442,10 +443,10 @@ static int __devinit snd_probe(struct usb_interface *intf, | |||
442 | struct snd_card *card; | 443 | struct snd_card *card; |
443 | struct usb_device *device = interface_to_usbdev(intf); | 444 | struct usb_device *device = interface_to_usbdev(intf); |
444 | 445 | ||
445 | card = create_card(device); | 446 | ret = create_card(device, &card); |
446 | 447 | ||
447 | if (!card) | 448 | if (ret < 0) |
448 | return -ENOMEM; | 449 | return ret; |
449 | 450 | ||
450 | usb_set_intfdata(intf, card); | 451 | usb_set_intfdata(intf, card); |
451 | ret = init_card(caiaqdev(card)); | 452 | ret = init_card(caiaqdev(card)); |
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) |
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 | ||
336 | static struct snd_card *usX2Y_create_card(struct usb_device *device) | 336 | static 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 | ||
372 | static void *usX2Y_usb_probe(struct usb_device *device, struct usb_interface *intf, const struct usb_device_id *device_id) | 373 | static 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 | */ |
393 | static int snd_usX2Y_probe(struct usb_interface *intf, const struct usb_device_id *id) | 403 | static 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 | ||
404 | static void snd_usX2Y_disconnect(struct usb_interface *intf) | 415 | static void snd_usX2Y_disconnect(struct usb_interface *intf) |