Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754571AbbGaOFx (ORCPT ); Fri, 31 Jul 2015 10:05:53 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:34706 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753123AbbGaOFt (ORCPT ); Fri, 31 Jul 2015 10:05:49 -0400 X-AuditID: cbfee61b-f79706d000001b96-e5-55bb80bb2998 From: Robert Baldyga To: balbi@ti.com Cc: gregkh@linuxfoundation.org, 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, stern@rowland.harvard.edu, petr.cvek@tul.cz, Robert Baldyga Subject: [PATCH v5 37/46] usb: gadget: epautoconf: add endpoint capabilities flags verification Date: Fri, 31 Jul 2015 16:00:49 +0200 Message-id: <1438351258-31578-38-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1438351258-31578-1-git-send-email-r.baldyga@samsung.com> References: <1438351258-31578-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWRbUhTYRiGe7eznW04Oh41XzTEDpoh5iqE3iAiiOpkQf1ICSHq5A6buM2x qaVQmlaWUVtIUFq6Wlaaudo0dfMjnSg1v9IQpeY0TVSiwmnTDaU26d913/cFz49HwCUrsQhB hiqb1agYBcUXYY71aWKnrdCWsmt+gELl8yUY6nQVoDaDE6BbLjsXFa0tYKi1z4ujYqOJj4bq 9yKbYxgg7ySJzNOjPKQbcGBoxPqIjyqe6TD09Pl1LvJ51nnodbcTRz/nz6A/I8U46qlY46Cq m/d5aNLegqPyHyFI7xviH4R02cxbDm3wNmL0RLsdo3X1bh69btdx6JZyJ053PK7DacuzAnrw wRNAVzhXAH23oRbQDR1uQPeONXHohzV3+LTbHEW3uX3YqeA00X4pq8jIZTWSA+dFcl3VN1zt irpkKWoChaAzvBQIBZBIgr0WL7bBW+DQhIlfCkQCkqgG0PvOyNkIqwC+aq8OWHwiATZ49MDP oQQBTXPDuF/iEisY7K+8jfuHEIKBzrpGnp8xIhYujV0L9GLiCBxc9fA3zkXBDz1lAUf4r182 9QcckjgMu3s+cvVAbACbagFk1elq7QWZco+KvZioZZTaHJUsMT1LaQaBr81GNgO79WgXIASA ChITRmsKyWNytXnKLgAFXCpU7NpuSyHFUiYvn9VkndPkKFhtF4gUYFS4WJJkTiEJGZPNZrKs mtX8XzkCYUQhuHxvx9T7PsvLtIFk/aQZwuap35bNJ9wt8vyvi8tanorKNP5qTr2h2Ccfl0uF o6OzsTJF8kJ89Ofvtb0xYVlnpyWtEsvCTHfNnJUKJq+UOB3UyUVljHDp0PiLMAN5rMB1WrRt zfclqCau/00a5UmdPZ6wNaRRGk3GyT7xrnIoTCtndsdzNVrmLw36giixAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4042 Lines: 143 Introduce endpoint matching mechanism basing on endpoint capabilities flags. We check if endpoint supports transfer type and direction requested in ep descriptor. Since we have this new endpoint matching mechanism there is no need to have old code guessing endpoint capabilities basing on its name, so we are getting rid of it. Remove also the obsolete comment. Signed-off-by: Robert Baldyga --- drivers/usb/gadget/epautoconf.c | 96 +++++++++++++---------------------------- 1 file changed, 30 insertions(+), 66 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 8e00ca7..af4b10a 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -22,22 +22,6 @@ #include "gadget_chips.h" -/* - * This should work with endpoints from controller drivers sharing the - * same endpoint naming convention. By example: - * - * - ep1, ep2, ... address is fixed, not direction or type - * - ep1in, ep2out, ... address and direction are fixed, not type - * - ep1-bulk, ep2-bulk, ... address and type are fixed, not direction - * - ep1in-bulk, ep2out-iso, ... all three are fixed - * - ep-* ... no functionality restrictions - * - * Type suffixes are "-bulk", "-iso", or "-int". Numbers are decimal. - * Less common restrictions are implied by gadget_is_*(). - * - * NOTE: each endpoint is unidirectional, as specified by its USB - * descriptor; and isn't specific to a configuration or altsetting. - */ static int ep_matches ( struct usb_gadget *gadget, @@ -47,7 +31,6 @@ ep_matches ( ) { u8 type; - const char *tmp; u16 max; int num_req_streams = 0; @@ -56,58 +39,39 @@ ep_matches ( if (ep->claimed) return 0; - /* only support ep0 for portable CONTROL traffic */ type = usb_endpoint_type(desc); - if (USB_ENDPOINT_XFER_CONTROL == type) - return 0; - - /* some other naming convention */ - if ('e' != ep->name[0]) + switch (type) { + case USB_ENDPOINT_XFER_CONTROL: + /* only support ep0 for portable CONTROL traffic */ return 0; + case USB_ENDPOINT_XFER_ISOC: + if (!ep->caps.type_iso) + return 0; + break; + case USB_ENDPOINT_XFER_BULK: + if (!ep->caps.type_bulk) + return 0; + break; + case USB_ENDPOINT_XFER_INT: + /* bulk endpoints handle interrupt transfers, + * except the toggle-quirky iso-synch kind + */ + if (!ep->caps.type_int && !ep->caps.type_bulk) + return 0; + /* for now, avoid PXA "interrupt-in"; + * it's documented as never using DATA1. + */ + if (gadget_is_pxa(gadget) && ep->caps.type_int) + return 0; + break; + } - /* type-restriction: "-iso", "-bulk", or "-int". - * direction-restriction: "in", "out". - */ - if ('-' != ep->name[2]) { - tmp = strrchr (ep->name, '-'); - if (tmp) { - switch (type) { - case USB_ENDPOINT_XFER_INT: - /* bulk endpoints handle interrupt transfers, - * except the toggle-quirky iso-synch kind - */ - if ('s' == tmp[2]) // == "-iso" - return 0; - /* for now, avoid PXA "interrupt-in"; - * it's documented as never using DATA1. - */ - if (gadget_is_pxa (gadget) - && 'i' == tmp [1]) - return 0; - break; - case USB_ENDPOINT_XFER_BULK: - if ('b' != tmp[1]) // != "-bulk" - return 0; - break; - case USB_ENDPOINT_XFER_ISOC: - if ('s' != tmp[2]) // != "-iso" - return 0; - } - } else { - tmp = ep->name + strlen (ep->name); - } - - /* direction-restriction: "..in-..", "out-.." */ - tmp--; - if (!isdigit (*tmp)) { - if (desc->bEndpointAddress & USB_DIR_IN) { - if ('n' != *tmp) - return 0; - } else { - if ('t' != *tmp) - return 0; - } - } + if (usb_endpoint_dir_in(desc)) { + if (!ep->caps.dir_in) + return 0; + } else { + if (!ep->caps.dir_out) + return 0; } /* -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/