diff options
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/caiaq/caiaq-device.c | 22 | ||||
-rw-r--r-- | sound/usb/usbaudio.c | 27 | ||||
-rw-r--r-- | sound/usb/usbmidi.c | 1 | ||||
-rw-r--r-- | sound/usb/usbmixer.c | 22 | ||||
-rw-r--r-- | sound/usb/usx2y/us122l.c | 59 | ||||
-rw-r--r-- | sound/usb/usx2y/usX2Yhwdep.c | 12 | ||||
-rw-r--r-- | sound/usb/usx2y/usbusx2y.c | 52 |
7 files changed, 98 insertions, 97 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 c709b9563226..8f3cdb37a0ec 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
@@ -2524,7 +2524,6 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
2524 | * build the rate table and bitmap flags | 2524 | * build the rate table and bitmap flags |
2525 | */ | 2525 | */ |
2526 | int r, idx; | 2526 | int r, idx; |
2527 | unsigned int nonzero_rates = 0; | ||
2528 | 2527 | ||
2529 | fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); | 2528 | fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); |
2530 | if (fp->rate_table == NULL) { | 2529 | if (fp->rate_table == NULL) { |
@@ -2532,24 +2531,27 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
2532 | return -1; | 2531 | return -1; |
2533 | } | 2532 | } |
2534 | 2533 | ||
2535 | fp->nr_rates = nr_rates; | 2534 | fp->nr_rates = 0; |
2536 | fp->rate_min = fp->rate_max = combine_triple(&fmt[8]); | 2535 | fp->rate_min = fp->rate_max = 0; |
2537 | for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) { | 2536 | for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) { |
2538 | unsigned int rate = combine_triple(&fmt[idx]); | 2537 | unsigned int rate = combine_triple(&fmt[idx]); |
2538 | if (!rate) | ||
2539 | continue; | ||
2539 | /* C-Media CM6501 mislabels its 96 kHz altsetting */ | 2540 | /* C-Media CM6501 mislabels its 96 kHz altsetting */ |
2540 | if (rate == 48000 && nr_rates == 1 && | 2541 | if (rate == 48000 && nr_rates == 1 && |
2541 | chip->usb_id == USB_ID(0x0d8c, 0x0201) && | 2542 | (chip->usb_id == USB_ID(0x0d8c, 0x0201) || |
2543 | chip->usb_id == USB_ID(0x0d8c, 0x0102)) && | ||
2542 | fp->altsetting == 5 && fp->maxpacksize == 392) | 2544 | fp->altsetting == 5 && fp->maxpacksize == 392) |
2543 | rate = 96000; | 2545 | rate = 96000; |
2544 | fp->rate_table[r] = rate; | 2546 | fp->rate_table[fp->nr_rates] = rate; |
2545 | nonzero_rates |= rate; | 2547 | if (!fp->rate_min || rate < fp->rate_min) |
2546 | if (rate < fp->rate_min) | ||
2547 | fp->rate_min = rate; | 2548 | fp->rate_min = rate; |
2548 | else if (rate > fp->rate_max) | 2549 | if (!fp->rate_max || rate > fp->rate_max) |
2549 | fp->rate_max = rate; | 2550 | fp->rate_max = rate; |
2550 | fp->rates |= snd_pcm_rate_to_rate_bit(rate); | 2551 | fp->rates |= snd_pcm_rate_to_rate_bit(rate); |
2552 | fp->nr_rates++; | ||
2551 | } | 2553 | } |
2552 | if (!nonzero_rates) { | 2554 | if (!fp->nr_rates) { |
2553 | hwc_debug("All rates were zero. Skipping format!\n"); | 2555 | hwc_debug("All rates were zero. Skipping format!\n"); |
2554 | return -1; | 2556 | return -1; |
2555 | } | 2557 | } |
@@ -2966,6 +2968,7 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip, | |||
2966 | return -EINVAL; | 2968 | return -EINVAL; |
2967 | } | 2969 | } |
2968 | alts = &iface->altsetting[fp->altset_idx]; | 2970 | alts = &iface->altsetting[fp->altset_idx]; |
2971 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | ||
2969 | usb_set_interface(chip->dev, fp->iface, 0); | 2972 | usb_set_interface(chip->dev, fp->iface, 0); |
2970 | init_usb_pitch(chip->dev, fp->iface, alts, fp); | 2973 | init_usb_pitch(chip->dev, fp->iface, alts, fp); |
2971 | init_usb_sample_rate(chip->dev, fp->iface, alts, fp, fp->rate_max); | 2974 | init_usb_sample_rate(chip->dev, fp->iface, alts, fp, fp->rate_max); |
@@ -3463,10 +3466,10 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, | |||
3463 | return -ENXIO; | 3466 | return -ENXIO; |
3464 | } | 3467 | } |
3465 | 3468 | ||
3466 | card = snd_card_new(index[idx], id[idx], THIS_MODULE, 0); | 3469 | err = snd_card_create(index[idx], id[idx], THIS_MODULE, 0, &card); |
3467 | if (card == NULL) { | 3470 | if (err < 0) { |
3468 | snd_printk(KERN_ERR "cannot create card instance %d\n", idx); | 3471 | snd_printk(KERN_ERR "cannot create card instance %d\n", idx); |
3469 | return -ENOMEM; | 3472 | return err; |
3470 | } | 3473 | } |
3471 | 3474 | ||
3472 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 3475 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c index 320641ab5be7..26bad373fe65 100644 --- a/sound/usb/usbmidi.c +++ b/sound/usb/usbmidi.c | |||
@@ -1625,6 +1625,7 @@ static int snd_usbmidi_create_endpoints_midiman(struct snd_usb_midi* umidi, | |||
1625 | } | 1625 | } |
1626 | 1626 | ||
1627 | ep_info.out_ep = get_endpoint(hostif, 2)->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; | 1627 | ep_info.out_ep = get_endpoint(hostif, 2)->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; |
1628 | ep_info.out_interval = 0; | ||
1628 | ep_info.out_cables = endpoint->out_cables & 0x5555; | 1629 | ep_info.out_cables = endpoint->out_cables & 0x5555; |
1629 | err = snd_usbmidi_out_endpoint_create(umidi, &ep_info, &umidi->endpoints[0]); | 1630 | err = snd_usbmidi_out_endpoint_create(umidi, &ep_info, &umidi->endpoints[0]); |
1630 | if (err < 0) | 1631 | if (err < 0) |
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c index 00397c8a765b..2bde79216fa5 100644 --- a/sound/usb/usbmixer.c +++ b/sound/usb/usbmixer.c | |||
@@ -78,7 +78,6 @@ struct usb_mixer_interface { | |||
78 | 78 | ||
79 | /* Sound Blaster remote control stuff */ | 79 | /* Sound Blaster remote control stuff */ |
80 | const struct rc_config *rc_cfg; | 80 | const struct rc_config *rc_cfg; |
81 | unsigned long rc_hwdep_open; | ||
82 | u32 rc_code; | 81 | u32 rc_code; |
83 | wait_queue_head_t rc_waitq; | 82 | wait_queue_head_t rc_waitq; |
84 | struct urb *rc_urb; | 83 | struct urb *rc_urb; |
@@ -1797,24 +1796,6 @@ static void snd_usb_soundblaster_remote_complete(struct urb *urb) | |||
1797 | wake_up(&mixer->rc_waitq); | 1796 | wake_up(&mixer->rc_waitq); |
1798 | } | 1797 | } |
1799 | 1798 | ||
1800 | static int snd_usb_sbrc_hwdep_open(struct snd_hwdep *hw, struct file *file) | ||
1801 | { | ||
1802 | struct usb_mixer_interface *mixer = hw->private_data; | ||
1803 | |||
1804 | if (test_and_set_bit(0, &mixer->rc_hwdep_open)) | ||
1805 | return -EBUSY; | ||
1806 | return 0; | ||
1807 | } | ||
1808 | |||
1809 | static int snd_usb_sbrc_hwdep_release(struct snd_hwdep *hw, struct file *file) | ||
1810 | { | ||
1811 | struct usb_mixer_interface *mixer = hw->private_data; | ||
1812 | |||
1813 | clear_bit(0, &mixer->rc_hwdep_open); | ||
1814 | smp_mb__after_clear_bit(); | ||
1815 | return 0; | ||
1816 | } | ||
1817 | |||
1818 | static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf, | 1799 | static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf, |
1819 | long count, loff_t *offset) | 1800 | long count, loff_t *offset) |
1820 | { | 1801 | { |
@@ -1867,9 +1848,8 @@ static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer) | |||
1867 | hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC; | 1848 | hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC; |
1868 | hwdep->private_data = mixer; | 1849 | hwdep->private_data = mixer; |
1869 | hwdep->ops.read = snd_usb_sbrc_hwdep_read; | 1850 | hwdep->ops.read = snd_usb_sbrc_hwdep_read; |
1870 | hwdep->ops.open = snd_usb_sbrc_hwdep_open; | ||
1871 | hwdep->ops.release = snd_usb_sbrc_hwdep_release; | ||
1872 | hwdep->ops.poll = snd_usb_sbrc_hwdep_poll; | 1851 | hwdep->ops.poll = snd_usb_sbrc_hwdep_poll; |
1852 | hwdep->exclusive = 1; | ||
1873 | 1853 | ||
1874 | mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL); | 1854 | mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL); |
1875 | if (!mixer->rc_urb) | 1855 | if (!mixer->rc_urb) |
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/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index fc650c800afc..4af8740db717 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c | |||
@@ -103,16 +103,6 @@ static unsigned int snd_us428ctls_poll(struct snd_hwdep *hw, struct file *file, | |||
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | static int snd_usX2Y_hwdep_open(struct snd_hwdep *hw, struct file *file) | ||
107 | { | ||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | static int snd_usX2Y_hwdep_release(struct snd_hwdep *hw, struct file *file) | ||
112 | { | ||
113 | return 0; | ||
114 | } | ||
115 | |||
116 | static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, | 106 | static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, |
117 | struct snd_hwdep_dsp_status *info) | 107 | struct snd_hwdep_dsp_status *info) |
118 | { | 108 | { |
@@ -264,8 +254,6 @@ int usX2Y_hwdep_new(struct snd_card *card, struct usb_device* device) | |||
264 | 254 | ||
265 | hw->iface = SNDRV_HWDEP_IFACE_USX2Y; | 255 | hw->iface = SNDRV_HWDEP_IFACE_USX2Y; |
266 | hw->private_data = usX2Y(card); | 256 | hw->private_data = usX2Y(card); |
267 | hw->ops.open = snd_usX2Y_hwdep_open; | ||
268 | hw->ops.release = snd_usX2Y_hwdep_release; | ||
269 | hw->ops.dsp_status = snd_usX2Y_hwdep_dsp_status; | 257 | hw->ops.dsp_status = snd_usX2Y_hwdep_dsp_status; |
270 | hw->ops.dsp_load = snd_usX2Y_hwdep_dsp_load; | 258 | hw->ops.dsp_load = snd_usX2Y_hwdep_dsp_load; |
271 | hw->ops.mmap = snd_us428ctls_mmap; | 259 | hw->ops.mmap = snd_us428ctls_mmap; |
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index c545a02dee48..5ce0da23ee96 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) |