From patchwork Wed Jun 20 11:00:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 10477015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7415B60532 for ; Wed, 20 Jun 2018 11:02:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62FAC28AD7 for ; Wed, 20 Jun 2018 11:02:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 579F828B47; Wed, 20 Jun 2018 11:02:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A1CC28B47 for ; Wed, 20 Jun 2018 11:02:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754139AbeFTLBf (ORCPT ); Wed, 20 Jun 2018 07:01:35 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:59907 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752914AbeFTLBe (ORCPT ); Wed, 20 Jun 2018 07:01:34 -0400 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1fVari-0003m6-OR; Wed, 20 Jun 2018 13:01:30 +0200 From: Sebastian Andrzej Siewior To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , linux-usb@vger.kernel.org, tglx@linutronix.de, Sebastian Andrzej Siewior , Hans Verkuil Subject: [PATCH 12/27] media: gspca: gspca: use usb_fill_XXX_urb() Date: Wed, 20 Jun 2018 13:00:50 +0200 Message-Id: <20180620110105.19955-13-bigeasy@linutronix.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620110105.19955-1-bigeasy@linutronix.de> References: <20180620110105.19955-1-bigeasy@linutronix.de> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Mauro Carvalho Chehab Signed-off-by: Sebastian Andrzej Siewior --- drivers/media/usb/gspca/gspca.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) 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;