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.c52
1 files changed, 33 insertions, 19 deletions
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
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;
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
369static 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)
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 */
390static 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)
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
401static void snd_usX2Y_disconnect(struct usb_interface *intf) 415static void snd_usX2Y_disconnect(struct usb_interface *intf)