From patchwork Tue Jul 14 09:39:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Baldyga X-Patchwork-Id: 6785351 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2889BC05AC for ; Tue, 14 Jul 2015 09:48:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4460020763 for ; Tue, 14 Jul 2015 09:48:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B4B02076E for ; Tue, 14 Jul 2015 09:48:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753932AbbGNJsd (ORCPT ); Tue, 14 Jul 2015 05:48:33 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:41324 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753499AbbGNJpV (ORCPT ); Tue, 14 Jul 2015 05:45:21 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NRH013DT1QVBQ10@mailout4.samsung.com>; Tue, 14 Jul 2015 18:44:55 +0900 (KST) X-AuditID: cbfee61a-f79516d000006302-e7-55a4da17a2a1 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id D6.B7.25346.71AD4A55; Tue, 14 Jul 2015 18:44:55 +0900 (KST) Received: from AMDC2122.DIGITAL.local ([106.120.53.17]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NRH00G1M1I4C080@mmp1.samsung.com>; Tue, 14 Jul 2015 18:44:55 +0900 (KST) From: Robert Baldyga To: gregkh@linuxfoundation.org, balbi@ti.com Cc: Peter.Chen@freescale.com, johnyoun@synopsys.com, dahlmann.thomas@arcor.de, nicolas.ferre@atmel.com, cernekee@gmail.com, leoli@freescale.com, daniel@zonque.org, haojian.zhuang@gmail.com, robert.jarzmik@free.fr, michal.simek@xilinx.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, linux-geode@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, andrzej.p@samsung.com, m.szyprowski@samsung.com, Robert Baldyga Subject: [PATCH v2 39/48] usb: gadget: epautoconf: remove ep and desc configuration from ep_matches() Date: Tue, 14 Jul 2015 11:39:27 +0200 Message-id: <1436866776-5004-40-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1436866776-5004-1-git-send-email-r.baldyga@samsung.com> References: <1436866776-5004-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmkeLIzCtJLcpLzFFi42I5/e+xgK74rSWhBt2PNCxmvWxnsTh4v95i 74K7jBad9w8zWzT9fcVisefML3aL5sXr2SwurDO32H36EqPFrwdCFpseX2O16D93msXi8q45 bBazl/SzWCxa1sps8fv7P1aLtUfuslu8exlh8e1yM7vFsdl/mSweHN7JbjHrjbCDmMfkJxuZ PBb82sricW/fYRaP/nWfWT3+He5n8tg56y67x/65a9g9Ni+p9zg/YyGjR9+WVYweW/Z/ZvQ4 fmM7k8fnTXIeez//ZvHYvns5SwB/FJdNSmpOZllqkb5dAlfGtaVLWQueSVbsfHicqYHxtkgX IyeHhICJxKrzp9kgbDGJC/fWA9lcHEICixgl2j+dYoVwfjJK7Hy3hhmkik1AR2LL9wmMILYI kL3u7w6wDmaBtSwSt94sYOli5OAQFkiX+PDIG6SGRUBVYtW/1SwgNq+Aq8Tp3lmMENvkJE4e m8wKYnMCxd/s+gN2hZCAi8SJ5svMExh5FzAyrGIUTS1ILihOSs811CtOzC0uzUvXS87P3cQI jqJnUjsYVzZYHGIU4GBU4uGdYLkkVIg1say4MvcQowQHs5IIr8VGoBBvSmJlVWpRfnxRaU5q 8SFGaQ4WJXHek/k+oUIC6YklqdmpqQWpRTBZJg5OqQbG2Qt1I/f+fbst8dhPfXPjk/a5i0s3 RApL9tdd/pTFfDfl+cUNTw/H1+jWeAVwn/s7/QgL+/kFKz6W8kg9lazZMSF/em770cOfc73f PlMW3aE+26Y/X0Zv5nnl1U7XKyxWyShkr9px5GOAn9alLiXJg3fya4IE5xr/iZ+l0JBsuG61 ndOqZfZrlViKMxINtZiLihMBV7SmzZ4CAAA= Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As function ep_matches() is used to match endpoint with usb descriptor it's highly unintuitive that it modifies endpoint and descriptor structures fields. This patch moves code configuring ep and desc from ep_matches() to usb_ep_autoconfig_ss(), so now function ep_matches() does nothing more than its name is suggesting. Signed-off-by: Robert Baldyga --- drivers/usb/gadget/epautoconf.c | 66 +++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 4f66e9d73..d00b443 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -82,13 +82,6 @@ ep_matches ( } - /* - * If the protocol driver hasn't yet decided on wMaxPacketSize - * and wants to know the maximum possible, provide the info. - */ - if (desc->wMaxPacketSize == 0) - desc->wMaxPacketSize = cpu_to_le16(ep->maxpacket_limit); - /* endpoint maxpacket size is an input parameter, except for bulk * where it's an output parameter representing the full speed limit. * the usb spec fixes high speed bulk maxpacket at 512 bytes. @@ -119,31 +112,6 @@ ep_matches ( /* MATCH!! */ - /* report address */ - desc->bEndpointAddress &= USB_DIR_IN; - if (isdigit (ep->name [2])) { - u8 num = simple_strtoul (&ep->name [2], NULL, 10); - desc->bEndpointAddress |= num; - } else if (desc->bEndpointAddress & USB_DIR_IN) { - if (++gadget->in_epnum > 15) - return 0; - desc->bEndpointAddress = USB_DIR_IN | gadget->in_epnum; - } else { - if (++gadget->out_epnum > 15) - return 0; - desc->bEndpointAddress |= gadget->out_epnum; - } - - /* report (variable) full speed bulk maxpacket */ - if ((USB_ENDPOINT_XFER_BULK == type) && !ep_comp) { - int size = ep->maxpacket_limit; - - /* min() doesn't work on bitfields with gcc-3.5 */ - if (size > 64) - size = 64; - desc->wMaxPacketSize = cpu_to_le16(size); - } - ep->address = desc->bEndpointAddress; return 1; } @@ -280,6 +248,40 @@ struct usb_ep *usb_ep_autoconfig_ss( /* Fail */ return NULL; found_ep: + + /* + * If the protocol driver hasn't yet decided on wMaxPacketSize + * and wants to know the maximum possible, provide the info. + */ + if (desc->wMaxPacketSize == 0) + desc->wMaxPacketSize = cpu_to_le16(ep->maxpacket_limit); + + /* report address */ + desc->bEndpointAddress &= USB_DIR_IN; + if (isdigit(ep->name[2])) { + u8 num = simple_strtoul(&ep->name[2], NULL, 10); + desc->bEndpointAddress |= num; + } else if (desc->bEndpointAddress & USB_DIR_IN) { + if (++gadget->in_epnum > 15) + return 0; + desc->bEndpointAddress = USB_DIR_IN | gadget->in_epnum; + } else { + if (++gadget->out_epnum > 15) + return 0; + desc->bEndpointAddress |= gadget->out_epnum; + } + + /* report (variable) full speed bulk maxpacket */ + if ((USB_ENDPOINT_XFER_BULK == type) && !ep_comp) { + int size = ep->maxpacket_limit; + + /* min() doesn't work on bitfields with gcc-3.5 */ + if (size > 64) + size = 64; + desc->wMaxPacketSize = cpu_to_le16(size); + } + + ep->address = desc->bEndpointAddress; ep->desc = NULL; ep->comp_desc = NULL; ep->claimed = true;