aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/usx2y/usbusx2y.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/usx2y/usbusx2y.c')
-rw-r--r--sound/usb/usx2y/usbusx2y.c45
1 files changed, 28 insertions, 17 deletions
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
336static struct snd_card *usX2Y_create_card(struct usb_device *device) 336static 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
372static void *usX2Y_usb_probe(struct usb_device *device, struct usb_interface *intf, const struct usb_device_id *device_id) 373static 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 */
393static int snd_usX2Y_probe(struct usb_interface *intf, const struct usb_device_id *id) 403static 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
404static void snd_usX2Y_disconnect(struct usb_interface *intf) 415static void snd_usX2Y_disconnect(struct usb_interface *intf)