diff mbox

[12/27] media: gspca: gspca: use usb_fill_XXX_urb()

Message ID 20180620110105.19955-13-bigeasy@linutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Sebastian Andrzej Siewior June 20, 2018, 11 a.m. UTC
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: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/media/usb/gspca/gspca.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
diff mbox

Patch

diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 57aa521e16b1..4cc9135829df 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -698,39 +698,40 @@  static int create_urbs(struct gspca_dev *gspca_dev,
 	}
 
 	for (n = 0; n < nurbs; n++) {
+		void *buf;
+
 		urb = usb_alloc_urb(npkt, GFP_KERNEL);
 		if (!urb)
 			return -ENOMEM;
 		gspca_dev->urb[n] = urb;
-		urb->transfer_buffer = usb_alloc_coherent(gspca_dev->dev,
+		buf = usb_alloc_coherent(gspca_dev->dev,
 						bsize,
 						GFP_KERNEL,
 						&urb->transfer_dma);
 
-		if (urb->transfer_buffer == NULL) {
+		if (buf == NULL) {
 			pr_err("usb_alloc_coherent failed\n");
 			return -ENOMEM;
 		}
-		urb->dev = gspca_dev->dev;
-		urb->context = gspca_dev;
-		urb->transfer_buffer_length = bsize;
 		if (npkt != 0) {		/* ISOC */
-			urb->pipe = usb_rcvisocpipe(gspca_dev->dev,
-						    ep->desc.bEndpointAddress);
+			usb_fill_int_urb(urb, gspca_dev->dev,
+					 usb_rcvisocpipe(gspca_dev->dev, ep->desc.bEndpointAddress),
+					 buf, bsize, isoc_irq, gspca_dev,
+					 ep->desc.bInterval);
+
 			urb->transfer_flags = URB_ISO_ASAP
 					| URB_NO_TRANSFER_DMA_MAP;
-			urb->interval = 1 << (ep->desc.bInterval - 1);
-			urb->complete = isoc_irq;
 			urb->number_of_packets = npkt;
 			for (i = 0; i < npkt; i++) {
 				urb->iso_frame_desc[i].length = psize;
 				urb->iso_frame_desc[i].offset = psize * i;
 			}
 		} else {		/* bulk */
-			urb->pipe = usb_rcvbulkpipe(gspca_dev->dev,
-						ep->desc.bEndpointAddress);
+			usb_fill_bulk_urb(urb, gspca_dev->dev,
+					 usb_rcvbulkpipe(gspca_dev->dev, ep->desc.bEndpointAddress),
+					 buf, bsize, bulk_irq, gspca_dev);
+
 			urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
-			urb->complete = bulk_irq;
 		}
 	}
 	return 0;