]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usb: gadget: add 'ep_match' callback to usb_gadget_ops
authorRobert Baldyga <r.baldyga@samsung.com>
Thu, 6 Aug 2015 12:11:10 +0000 (14:11 +0200)
committerFelipe Balbi <balbi@ti.com>
Thu, 6 Aug 2015 14:31:45 +0000 (09:31 -0500)
Add callback that is called by epautoconf to allow UDC driver match the
best endpoint for specific descriptor. It's intended to supply mechanism
which allows to get rid of chip-specific endpoint matching code from
epautoconf.

If gadget has set 'ep_match' callback we prefer to call it first, and
if it fails to find matching endpoint, then we try to use default matching
algorithm.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/epautoconf.c
include/linux/usb/gadget.h

index 95e12759af4d9ae0890f365e6b16c1e7e2be33df..f000c73319f49eb08fc4d933a7b6c468f7e3baed 100644 (file)
@@ -165,6 +165,12 @@ struct usb_ep *usb_ep_autoconfig_ss(
 
        type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
 
+       if (gadget->ops->match_ep) {
+               ep = gadget->ops->match_ep(gadget, desc, ep_comp);
+               if (ep)
+                       goto found_ep;
+       }
+
        /* First, apply chip-specific "best usage" knowledge.
         * This might make a good usb_gadget_ops hook ...
         */
index 82b5bcbd2c9841e447b327d40e31d6434c5e1b9f..303214bb2f8b1ce50d4c9a020e4c8719ed9b5d80 100644 (file)
@@ -534,6 +534,9 @@ struct usb_gadget_ops {
        int     (*udc_start)(struct usb_gadget *,
                        struct usb_gadget_driver *);
        int     (*udc_stop)(struct usb_gadget *);
+       struct usb_ep *(*match_ep)(struct usb_gadget *,
+                       struct usb_endpoint_descriptor *,
+                       struct usb_ss_ep_comp_descriptor *);
 };
 
 /**