diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-03-23 19:35:35 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-03-23 19:35:35 -0400 |
commit | dec14f8c0eff54549e5747f8a4d1dc6c0347e2dd (patch) | |
tree | af1744c17c4bacad4c9524ad096d5a65f6c25c73 /sound/usb | |
parent | 8e0ee43bc2c3e19db56a4adaa9a9b04ce885cd84 (diff) | |
parent | b1a0aac05f044e78a589bfd7a9e2334aa640eb45 (diff) |
Merge branch 'topic/snd_card_new-err' into for-linus
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/caiaq/caiaq-device.c | 22 | ||||
-rw-r--r-- | sound/usb/usbaudio.c | 6 | ||||
-rw-r--r-- | sound/usb/usx2y/us122l.c | 59 | ||||
-rw-r--r-- | sound/usb/usx2y/usbusx2y.c | 52 |
4 files changed, 84 insertions, 55 deletions
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c index 41c36b055f6b..09aed2363cc9 100644 --- a/sound/usb/caiaq/caiaq-device.c +++ b/sound/usb/caiaq/caiaq-device.c | |||
@@ -336,9 +336,10 @@ 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 | struct snd_card *card; | 343 | struct snd_card *card; |
343 | struct snd_usb_caiaqdev *dev; | 344 | struct snd_usb_caiaqdev *dev; |
344 | 345 | ||
@@ -347,12 +348,12 @@ static struct snd_card* create_card(struct usb_device* usb_dev) | |||
347 | break; | 348 | break; |
348 | 349 | ||
349 | if (devnum >= SNDRV_CARDS) | 350 | if (devnum >= SNDRV_CARDS) |
350 | return NULL; | 351 | return -ENODEV; |
351 | 352 | ||
352 | card = snd_card_new(index[devnum], id[devnum], THIS_MODULE, | 353 | err = snd_card_create(index[devnum], id[devnum], THIS_MODULE, |
353 | sizeof(struct snd_usb_caiaqdev)); | 354 | sizeof(struct snd_usb_caiaqdev), &card); |
354 | if (!card) | 355 | if (err < 0) |
355 | return NULL; | 356 | return err; |
356 | 357 | ||
357 | dev = caiaqdev(card); | 358 | dev = caiaqdev(card); |
358 | dev->chip.dev = usb_dev; | 359 | dev->chip.dev = usb_dev; |
@@ -362,7 +363,8 @@ static struct snd_card* create_card(struct usb_device* usb_dev) | |||
362 | spin_lock_init(&dev->spinlock); | 363 | spin_lock_init(&dev->spinlock); |
363 | snd_card_set_dev(card, &usb_dev->dev); | 364 | snd_card_set_dev(card, &usb_dev->dev); |
364 | 365 | ||
365 | return card; | 366 | *cardp = card; |
367 | return 0; | ||
366 | } | 368 | } |
367 | 369 | ||
368 | static int __devinit init_card(struct snd_usb_caiaqdev *dev) | 370 | static int __devinit init_card(struct snd_usb_caiaqdev *dev) |
@@ -441,10 +443,10 @@ static int __devinit snd_probe(struct usb_interface *intf, | |||
441 | struct snd_card *card; | 443 | struct snd_card *card; |
442 | struct usb_device *device = interface_to_usbdev(intf); | 444 | struct usb_device *device = interface_to_usbdev(intf); |
443 | 445 | ||
444 | card = create_card(device); | 446 | ret = create_card(device, &card); |
445 | 447 | ||
446 | if (!card) | 448 | if (ret < 0) |
447 | return -ENOMEM; | 449 | return ret; |
448 | 450 | ||
449 | usb_set_intfdata(intf, card); | 451 | usb_set_intfdata(intf, card); |
450 | ret = init_card(caiaqdev(card)); | 452 | ret = init_card(caiaqdev(card)); |
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 19e37451c216..8f3cdb37a0ec 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
@@ -3466,10 +3466,10 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, | |||
3466 | return -ENXIO; | 3466 | return -ENXIO; |
3467 | } | 3467 | } |
3468 | 3468 | ||
3469 | card = snd_card_new(index[idx], id[idx], THIS_MODULE, 0); | 3469 | err = snd_card_create(index[idx], id[idx], THIS_MODULE, 0, &card); |
3470 | if (card == NULL) { | 3470 | if (err < 0) { |
3471 | snd_printk(KERN_ERR "cannot create card instance %d\n", idx); | 3471 | snd_printk(KERN_ERR "cannot create card instance %d\n", idx); |
3472 | return -ENOMEM; | 3472 | return err; |
3473 | } | 3473 | } |
3474 | 3474 | ||
3475 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 3475 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
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 | ||
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; |
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 | ||
515 | static void *us122l_usb_probe(struct usb_interface *intf, | 518 | static 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 | ||
534 | static int snd_us122l_probe(struct usb_interface *intf, | 546 | static 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 | ||
554 | 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 11639bd72a51..af8b84954054 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c | |||
@@ -333,18 +333,21 @@ 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; |
340 | int err; | ||
341 | |||
340 | for (dev = 0; dev < SNDRV_CARDS; ++dev) | 342 | for (dev = 0; dev < SNDRV_CARDS; ++dev) |
341 | if (enable[dev] && !snd_usX2Y_card_used[dev]) | 343 | if (enable[dev] && !snd_usX2Y_card_used[dev]) |
342 | break; | 344 | break; |
343 | if (dev >= SNDRV_CARDS) | 345 | if (dev >= SNDRV_CARDS) |
344 | return NULL; | 346 | return -ENODEV; |
345 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct usX2Ydev)); | 347 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, |
346 | if (!card) | 348 | sizeof(struct usX2Ydev), &card); |
347 | return NULL; | 349 | if (err < 0) |
350 | return err; | ||
348 | snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1; | 351 | snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1; |
349 | card->private_free = snd_usX2Y_card_private_free; | 352 | card->private_free = snd_usX2Y_card_private_free; |
350 | usX2Y(card)->chip.dev = device; | 353 | usX2Y(card)->chip.dev = device; |
@@ -362,26 +365,36 @@ static struct snd_card *usX2Y_create_card(struct usb_device *device) | |||
362 | usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum | 365 | usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum |
363 | ); | 366 | ); |
364 | snd_card_set_dev(card, &device->dev); | 367 | snd_card_set_dev(card, &device->dev); |
365 | return card; | 368 | *cardp = card; |
369 | return 0; | ||
366 | } | 370 | } |
367 | 371 | ||
368 | 372 | ||
369 | 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) | ||
370 | { | 377 | { |
371 | int err; | 378 | int err; |
372 | struct snd_card * card; | 379 | struct snd_card * card; |
380 | |||
381 | *cardp = NULL; | ||
373 | if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 || | 382 | if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 || |
374 | (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 && | 383 | (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 && |
375 | le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 && | 384 | le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 && |
376 | le16_to_cpu(device->descriptor.idProduct) != USB_ID_US428) || | 385 | le16_to_cpu(device->descriptor.idProduct) != USB_ID_US428)) |
377 | !(card = usX2Y_create_card(device))) | 386 | return -EINVAL; |
378 | return NULL; | 387 | |
388 | err = usX2Y_create_card(device, &card); | ||
389 | if (err < 0) | ||
390 | return err; | ||
379 | if ((err = usX2Y_hwdep_new(card, device)) < 0 || | 391 | if ((err = usX2Y_hwdep_new(card, device)) < 0 || |
380 | (err = snd_card_register(card)) < 0) { | 392 | (err = snd_card_register(card)) < 0) { |
381 | snd_card_free(card); | 393 | snd_card_free(card); |
382 | return NULL; | 394 | return err; |
383 | } | 395 | } |
384 | return card; | 396 | *cardp = card; |
397 | return 0; | ||
385 | } | 398 | } |
386 | 399 | ||
387 | /* | 400 | /* |
@@ -389,13 +402,14 @@ static void *usX2Y_usb_probe(struct usb_device *device, struct usb_interface *in | |||
389 | */ | 402 | */ |
390 | 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) |
391 | { | 404 | { |
392 | void *chip; | 405 | struct snd_card *card; |
393 | chip = usX2Y_usb_probe(interface_to_usbdev(intf), intf, id); | 406 | int err; |
394 | if (chip) { | 407 | |
395 | usb_set_intfdata(intf, chip); | 408 | err = usX2Y_usb_probe(interface_to_usbdev(intf), intf, id, &card); |
396 | return 0; | 409 | if (err < 0) |
397 | } else | 410 | return err; |
398 | return -EIO; | 411 | dev_set_drvdata(&intf->dev, card); |
412 | return 0; | ||
399 | } | 413 | } |
400 | 414 | ||
401 | static void snd_usX2Y_disconnect(struct usb_interface *intf) | 415 | static void snd_usX2Y_disconnect(struct usb_interface *intf) |