summaryrefslogtreecommitdiffstats
path: root/sound/usb/line6
diff options
context:
space:
mode:
authorTakashi Iwai2015-01-19 14:41:57 +0100
committerTakashi Iwai2015-01-20 08:14:55 +0100
commitb45a7c565473d29bd7e02ac8ca86232a24ca247f (patch)
tree91debcffbe4be26cd475406cb5496d546fc3af7f /sound/usb/line6
parentALSA: line6: Handle impulse response via control API (diff)
downloadkernel-qcow2-linux-b45a7c565473d29bd7e02ac8ca86232a24ca247f.tar.gz
kernel-qcow2-linux-b45a7c565473d29bd7e02ac8ca86232a24ca247f.tar.xz
kernel-qcow2-linux-b45a7c565473d29bd7e02ac8ca86232a24ca247f.zip
ALSA: line6: Drop superfluous snd_device for PCM
Instead of handling the card-specific resource in snd_device, attach it into pcm->private_data and release it directly in private_free. This simplifies the code and structure. Tested-by: Chris Rorvick <chris@rorvick.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/line6')
-rw-r--r--sound/usb/line6/pcm.c53
1 files changed, 19 insertions, 34 deletions
diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c
index 626b6c158023..520cf540e83c 100644
--- a/sound/usb/line6/pcm.c
+++ b/sound/usb/line6/pcm.c
@@ -351,24 +351,21 @@ static void line6_cleanup_pcm(struct snd_pcm *pcm)
usb_free_urb(line6pcm->urb_audio_in[i]);
}
}
+ kfree(line6pcm);
}
/* create a PCM device */
-static int snd_line6_new_pcm(struct snd_line6_pcm *line6pcm)
+static int snd_line6_new_pcm(struct usb_line6 *line6, struct snd_pcm **pcm_ret)
{
struct snd_pcm *pcm;
int err;
- err = snd_pcm_new(line6pcm->line6->card,
- (char *)line6pcm->line6->properties->name,
- 0, 1, 1, &pcm);
+ err = snd_pcm_new(line6->card, (char *)line6->properties->name,
+ 0, 1, 1, pcm_ret);
if (err < 0)
return err;
-
- pcm->private_data = line6pcm;
- pcm->private_free = line6_cleanup_pcm;
- line6pcm->pcm = pcm;
- strcpy(pcm->name, line6pcm->line6->properties->name);
+ pcm = *pcm_ret;
+ strcpy(pcm->name, line6->properties->name);
/* set operators */
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
@@ -380,13 +377,6 @@ static int snd_line6_new_pcm(struct snd_line6_pcm *line6pcm)
snd_dma_continuous_data
(GFP_KERNEL), 64 * 1024,
128 * 1024);
-
- return 0;
-}
-
-/* PCM device destructor */
-static int snd_line6_pcm_free(struct snd_device *device)
-{
return 0;
}
@@ -423,23 +413,25 @@ EXPORT_SYMBOL_GPL(line6_pcm_disconnect);
int line6_init_pcm(struct usb_line6 *line6,
struct line6_pcm_properties *properties)
{
- static struct snd_device_ops pcm_ops = {
- .dev_free = snd_line6_pcm_free,
- };
-
int i, err;
unsigned ep_read = line6->properties->ep_audio_r;
unsigned ep_write = line6->properties->ep_audio_w;
+ struct snd_pcm *pcm;
struct snd_line6_pcm *line6pcm;
if (!(line6->properties->capabilities & LINE6_CAP_PCM))
return 0; /* skip PCM initialization and report success */
- line6pcm = kzalloc(sizeof(*line6pcm), GFP_KERNEL);
+ err = snd_line6_new_pcm(line6, &pcm);
+ if (err < 0)
+ return err;
- if (line6pcm == NULL)
+ line6pcm = kzalloc(sizeof(*line6pcm), GFP_KERNEL);
+ if (!line6pcm)
return -ENOMEM;
+ line6pcm->pcm = pcm;
+ line6pcm->properties = properties;
line6pcm->volume_playback[0] = line6pcm->volume_playback[1] = 255;
line6pcm->volume_monitor = 255;
line6pcm->line6 = line6;
@@ -451,23 +443,16 @@ int line6_init_pcm(struct usb_line6 *line6,
usb_maxpacket(line6->usbdev,
usb_sndisocpipe(line6->usbdev, ep_write), 1));
- line6pcm->properties = properties;
- line6->line6pcm = line6pcm;
-
- /* PCM device: */
- err = snd_device_new(line6->card, SNDRV_DEV_PCM, line6, &pcm_ops);
- if (err < 0)
- return err;
-
- err = snd_line6_new_pcm(line6pcm);
- if (err < 0)
- return err;
-
spin_lock_init(&line6pcm->lock_audio_out);
spin_lock_init(&line6pcm->lock_audio_in);
spin_lock_init(&line6pcm->lock_trigger);
line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD;
+ line6->line6pcm = line6pcm;
+
+ pcm->private_data = line6pcm;
+ pcm->private_free = line6_cleanup_pcm;
+
err = line6_create_audio_out_urbs(line6pcm);
if (err < 0)
return err;