[alsa-devel] [PATCH 6/9] ALSA: usb: caiaq: use usb_fill_int_urb()
Sebastian Andrzej Siewior
bigeasy at linutronix.de
Tue Jun 19 23:55:18 CEST 2018
Using usb_fill_int_urb() helps to find code which initializes an
URB. A grep for members of the struct (like ->complete) reveal lots
of other things, too.
Cc: Daniel Mack <zonque at gmail.com>
Cc: Jaroslav Kysela <perex at perex.cz>
Cc: Takashi Iwai <tiwai at suse.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy at linutronix.de>
---
sound/usb/caiaq/audio.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c
index 15344d39a6cd..e10d5790099f 100644
--- a/sound/usb/caiaq/audio.c
+++ b/sound/usb/caiaq/audio.c
@@ -736,16 +736,17 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
}
for (i = 0; i < N_URBS; i++) {
+ void *buf;
+
urbs[i] = usb_alloc_urb(FRAMES_PER_URB, GFP_KERNEL);
if (!urbs[i]) {
*ret = -ENOMEM;
return urbs;
}
- urbs[i]->transfer_buffer =
- kmalloc_array(BYTES_PER_FRAME, FRAMES_PER_URB,
- GFP_KERNEL);
- if (!urbs[i]->transfer_buffer) {
+ buf = kmalloc_array(BYTES_PER_FRAME, FRAMES_PER_URB,
+ GFP_KERNEL);
+ if (!buf) {
*ret = -ENOMEM;
return urbs;
}
@@ -758,15 +759,13 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
iso->length = BYTES_PER_FRAME;
}
- urbs[i]->dev = usb_dev;
- urbs[i]->pipe = pipe;
- urbs[i]->transfer_buffer_length = FRAMES_PER_URB
- * BYTES_PER_FRAME;
- urbs[i]->context = &cdev->data_cb_info[i];
- urbs[i]->interval = 1;
+ usb_fill_int_urb(urbs[i], usb_dev, pipe, buf,
+ FRAMES_PER_URB * BYTES_PER_FRAME,
+ (dir == SNDRV_PCM_STREAM_CAPTURE) ?
+ read_completed : write_completed,
+ &cdev->data_cb_info[i], 1);
+
urbs[i]->number_of_packets = FRAMES_PER_URB;
- urbs[i]->complete = (dir == SNDRV_PCM_STREAM_CAPTURE) ?
- read_completed : write_completed;
}
*ret = 0;
--
2.17.1
More information about the Alsa-devel
mailing list