Start matching endpoints against feature flags,
this will help us dropping the naming conventions
currently used by the Gadget Framework.

Signed-off-by: Felipe Balbi <ba...@ti.com>
---
 drivers/usb/gadget/epautoconf.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index feaaa7b..3fe0d42 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -62,6 +62,31 @@ ep_matches (
        if (USB_ENDPOINT_XFER_CONTROL == type)
                return 0;
 
+       /* first check feature flags */
+       if (ep->has_dir_in ^ usb_endpoint_dir_in(desc))
+               return 0;
+
+       if (ep->has_dir_out ^ usb_endpoint_dir_out(desc))
+               return 0;
+
+       switch (type) {
+       case USB_ENDPOINT_XFER_CONTROL:
+               /* only ep0 */
+               return 0;
+       case USB_ENDPOINT_XFER_BULK:
+               if (ep->has_bulk)
+                       goto match;
+               break;
+       case USB_ENDPOINT_XFER_INT:
+               if (ep->has_interrupt)
+                       goto match;
+               break;
+       case USB_ENDPOINT_XFER_ISOC:
+               if (ep->has_isochronous)
+                       goto match;
+               break;
+       }
+
        /* some other naming convention */
        if ('e' != ep->name[0])
                return 0;
@@ -159,8 +184,7 @@ ep_matches (
                break;
        }
 
-       /* MATCH!! */
-
+match:
        /* report address */
        desc->bEndpointAddress &= USB_DIR_IN;
        if (isdigit (ep->name [2])) {
-- 
1.8.4.GIT

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to