Commit 874b8d42 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: usb: Convert to snd_card_new() with a device pointer

Also remove superfluous snd_card_set_dev() calls.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 60c5772b
...@@ -124,8 +124,8 @@ static int usb6fire_chip_probe(struct usb_interface *intf, ...@@ -124,8 +124,8 @@ static int usb6fire_chip_probe(struct usb_interface *intf,
snd_printk(KERN_ERR PREFIX "can't set first interface.\n"); snd_printk(KERN_ERR PREFIX "can't set first interface.\n");
return -EIO; return -EIO;
} }
ret = snd_card_create(index[regidx], id[regidx], THIS_MODULE, ret = snd_card_new(&intf->dev, index[regidx], id[regidx],
sizeof(struct sfire_chip), &card); THIS_MODULE, sizeof(struct sfire_chip), &card);
if (ret < 0) { if (ret < 0) {
snd_printk(KERN_ERR PREFIX "cannot create alsa card.\n"); snd_printk(KERN_ERR PREFIX "cannot create alsa card.\n");
return ret; return ret;
...@@ -134,7 +134,6 @@ static int usb6fire_chip_probe(struct usb_interface *intf, ...@@ -134,7 +134,6 @@ static int usb6fire_chip_probe(struct usb_interface *intf,
strcpy(card->shortname, "TerraTec DMX6FireUSB"); strcpy(card->shortname, "TerraTec DMX6FireUSB");
sprintf(card->longname, "%s at %d:%d", card->shortname, sprintf(card->longname, "%s at %d:%d", card->shortname,
device->bus->busnum, device->devnum); device->bus->busnum, device->devnum);
snd_card_set_dev(card, &intf->dev);
chip = card->private_data; chip = card->private_data;
chips[regidx] = chip; chips[regidx] = chip;
......
...@@ -418,8 +418,9 @@ static int create_card(struct usb_device *usb_dev, ...@@ -418,8 +418,9 @@ static int create_card(struct usb_device *usb_dev,
if (devnum >= SNDRV_CARDS) if (devnum >= SNDRV_CARDS)
return -ENODEV; return -ENODEV;
err = snd_card_create(index[devnum], id[devnum], THIS_MODULE, err = snd_card_new(&intf->dev,
sizeof(struct snd_usb_caiaqdev), &card); index[devnum], id[devnum], THIS_MODULE,
sizeof(struct snd_usb_caiaqdev), &card);
if (err < 0) if (err < 0)
return err; return err;
...@@ -429,7 +430,6 @@ static int create_card(struct usb_device *usb_dev, ...@@ -429,7 +430,6 @@ static int create_card(struct usb_device *usb_dev,
cdev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor), cdev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor),
le16_to_cpu(usb_dev->descriptor.idProduct)); le16_to_cpu(usb_dev->descriptor.idProduct));
spin_lock_init(&cdev->spinlock); spin_lock_init(&cdev->spinlock);
snd_card_set_dev(card, &intf->dev);
*cardp = card; *cardp = card;
return 0; return 0;
......
...@@ -328,7 +328,8 @@ static void remove_trailing_spaces(char *str) ...@@ -328,7 +328,8 @@ static void remove_trailing_spaces(char *str)
/* /*
* create a chip instance and set its names. * create a chip instance and set its names.
*/ */
static int snd_usb_audio_create(struct usb_device *dev, int idx, static int snd_usb_audio_create(struct usb_interface *intf,
struct usb_device *dev, int idx,
const struct snd_usb_audio_quirk *quirk, const struct snd_usb_audio_quirk *quirk,
struct snd_usb_audio **rchip) struct snd_usb_audio **rchip)
{ {
...@@ -354,7 +355,8 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, ...@@ -354,7 +355,8 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
return -ENXIO; return -ENXIO;
} }
err = snd_card_create(index[idx], id[idx], THIS_MODULE, 0, &card); err = snd_card_new(&intf->dev, index[idx], id[idx], THIS_MODULE,
0, &card);
if (err < 0) { if (err < 0) {
snd_printk(KERN_ERR "cannot create card instance %d\n", idx); snd_printk(KERN_ERR "cannot create card instance %d\n", idx);
return err; return err;
...@@ -513,10 +515,10 @@ snd_usb_audio_probe(struct usb_device *dev, ...@@ -513,10 +515,10 @@ snd_usb_audio_probe(struct usb_device *dev,
if (enable[i] && ! usb_chip[i] && if (enable[i] && ! usb_chip[i] &&
(vid[i] == -1 || vid[i] == USB_ID_VENDOR(id)) && (vid[i] == -1 || vid[i] == USB_ID_VENDOR(id)) &&
(pid[i] == -1 || pid[i] == USB_ID_PRODUCT(id))) { (pid[i] == -1 || pid[i] == USB_ID_PRODUCT(id))) {
if (snd_usb_audio_create(dev, i, quirk, &chip) < 0) { if (snd_usb_audio_create(intf, dev, i, quirk,
&chip) < 0) {
goto __error; goto __error;
} }
snd_card_set_dev(chip->card, &intf->dev);
chip->pm_intf = intf; chip->pm_intf = intf;
break; break;
} }
......
...@@ -64,7 +64,8 @@ struct hiface_vendor_quirk { ...@@ -64,7 +64,8 @@ struct hiface_vendor_quirk {
u8 extra_freq; u8 extra_freq;
}; };
static int hiface_chip_create(struct usb_device *device, int idx, static int hiface_chip_create(struct usb_interface *intf,
struct usb_device *device, int idx,
const struct hiface_vendor_quirk *quirk, const struct hiface_vendor_quirk *quirk,
struct hiface_chip **rchip) struct hiface_chip **rchip)
{ {
...@@ -76,7 +77,8 @@ static int hiface_chip_create(struct usb_device *device, int idx, ...@@ -76,7 +77,8 @@ static int hiface_chip_create(struct usb_device *device, int idx,
*rchip = NULL; *rchip = NULL;
/* if we are here, card can be registered in alsa. */ /* if we are here, card can be registered in alsa. */
ret = snd_card_create(index[idx], id[idx], THIS_MODULE, sizeof(*chip), &card); ret = snd_card_new(&intf->dev, index[idx], id[idx], THIS_MODULE,
sizeof(*chip), &card);
if (ret < 0) { if (ret < 0) {
dev_err(&device->dev, "cannot create alsa card.\n"); dev_err(&device->dev, "cannot create alsa card.\n");
return ret; return ret;
...@@ -132,12 +134,10 @@ static int hiface_chip_probe(struct usb_interface *intf, ...@@ -132,12 +134,10 @@ static int hiface_chip_probe(struct usb_interface *intf,
goto err; goto err;
} }
ret = hiface_chip_create(device, i, quirk, &chip); ret = hiface_chip_create(intf, device, i, quirk, &chip);
if (ret < 0) if (ret < 0)
goto err; goto err;
snd_card_set_dev(chip->card, &intf->dev);
ret = hiface_pcm_init(chip, quirk ? quirk->extra_freq : 0); ret = hiface_pcm_init(chip, quirk ? quirk->extra_freq : 0);
if (ret < 0) if (ret < 0)
goto err_chip_destroy; goto err_chip_destroy;
......
...@@ -1243,8 +1243,9 @@ static int ua101_probe(struct usb_interface *interface, ...@@ -1243,8 +1243,9 @@ static int ua101_probe(struct usb_interface *interface,
mutex_unlock(&devices_mutex); mutex_unlock(&devices_mutex);
return -ENOENT; return -ENOENT;
} }
err = snd_card_create(index[card_index], id[card_index], THIS_MODULE, err = snd_card_new(&interface->dev,
sizeof(*ua), &card); index[card_index], id[card_index], THIS_MODULE,
sizeof(*ua), &card);
if (err < 0) { if (err < 0) {
mutex_unlock(&devices_mutex); mutex_unlock(&devices_mutex);
return err; return err;
...@@ -1283,8 +1284,6 @@ static int ua101_probe(struct usb_interface *interface, ...@@ -1283,8 +1284,6 @@ static int ua101_probe(struct usb_interface *interface,
} }
} }
snd_card_set_dev(card, &interface->dev);
err = detect_usb_format(ua); err = detect_usb_format(ua);
if (err < 0) if (err < 0)
goto probe_error; goto probe_error;
......
...@@ -535,7 +535,9 @@ static void snd_us122l_free(struct snd_card *card) ...@@ -535,7 +535,9 @@ static void snd_us122l_free(struct snd_card *card)
snd_us122l_card_used[index] = 0; snd_us122l_card_used[index] = 0;
} }
static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) static int usx2y_create_card(struct usb_device *device,
struct usb_interface *intf,
struct snd_card **cardp)
{ {
int dev; int dev;
struct snd_card *card; struct snd_card *card;
...@@ -546,8 +548,8 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) ...@@ -546,8 +548,8 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
break; break;
if (dev >= SNDRV_CARDS) if (dev >= SNDRV_CARDS)
return -ENODEV; return -ENODEV;
err = snd_card_create(index[dev], id[dev], THIS_MODULE, err = snd_card_new(&intf->dev, index[dev], id[dev], THIS_MODULE,
sizeof(struct us122l), &card); sizeof(struct us122l), &card);
if (err < 0) if (err < 0)
return err; return err;
snd_us122l_card_used[US122L(card)->card_index = dev] = 1; snd_us122l_card_used[US122L(card)->card_index = dev] = 1;
...@@ -578,11 +580,10 @@ static int us122l_usb_probe(struct usb_interface *intf, ...@@ -578,11 +580,10 @@ static int us122l_usb_probe(struct usb_interface *intf,
struct snd_card *card; struct snd_card *card;
int err; int err;
err = usx2y_create_card(device, &card); err = usx2y_create_card(device, intf, &card);
if (err < 0) if (err < 0)
return err; return err;
snd_card_set_dev(card, &intf->dev);
if (!us122l_create_card(card)) { if (!us122l_create_card(card)) {
snd_card_free(card); snd_card_free(card);
return -EINVAL; return -EINVAL;
......
...@@ -332,7 +332,9 @@ static struct usb_device_id snd_usX2Y_usb_id_table[] = { ...@@ -332,7 +332,9 @@ static struct usb_device_id snd_usX2Y_usb_id_table[] = {
{ /* terminator */ } { /* terminator */ }
}; };
static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp) static int usX2Y_create_card(struct usb_device *device,
struct usb_interface *intf,
struct snd_card **cardp)
{ {
int dev; int dev;
struct snd_card * card; struct snd_card * card;
...@@ -343,8 +345,8 @@ static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp) ...@@ -343,8 +345,8 @@ static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp)
break; break;
if (dev >= SNDRV_CARDS) if (dev >= SNDRV_CARDS)
return -ENODEV; return -ENODEV;
err = snd_card_create(index[dev], id[dev], THIS_MODULE, err = snd_card_new(&intf->dev, index[dev], id[dev], THIS_MODULE,
sizeof(struct usX2Ydev), &card); sizeof(struct usX2Ydev), &card);
if (err < 0) if (err < 0)
return err; return err;
snd_usX2Y_card_used[usX2Y(card)->card_index = dev] = 1; snd_usX2Y_card_used[usX2Y(card)->card_index = dev] = 1;
...@@ -382,10 +384,9 @@ static int usX2Y_usb_probe(struct usb_device *device, ...@@ -382,10 +384,9 @@ static int usX2Y_usb_probe(struct usb_device *device,
le16_to_cpu(device->descriptor.idProduct) != USB_ID_US428)) le16_to_cpu(device->descriptor.idProduct) != USB_ID_US428))
return -EINVAL; return -EINVAL;
err = usX2Y_create_card(device, &card); err = usX2Y_create_card(device, intf, &card);
if (err < 0) if (err < 0)
return err; return err;
snd_card_set_dev(card, &intf->dev);
if ((err = usX2Y_hwdep_new(card, device)) < 0 || if ((err = usX2Y_hwdep_new(card, device)) < 0 ||
(err = snd_card_register(card)) < 0) { (err = snd_card_register(card)) < 0) {
snd_card_free(card); snd_card_free(card);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment