usb: gadget: net2280: add net2280_match_ep() function
authorRobert Baldyga <r.baldyga@samsung.com>
Thu, 6 Aug 2015 12:11:13 +0000 (14:11 +0200)
committerFelipe Balbi <balbi@ti.com>
Thu, 6 Aug 2015 14:33:38 +0000 (09:33 -0500)
Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching
process. Function does the same that was done by chip-specific code inside
of epautoconf. Now this code can be removed from there to separate generic code
from platform specific logic.

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

index a39ca033b9ceabfe4125cbaa568c4492f866029d..0ff513400ecf9f48ddf89bb3c8cb5ac7a2c85593 100644 (file)
@@ -86,28 +86,7 @@ struct usb_ep *usb_ep_autoconfig_ss(
        /* First, apply chip-specific "best usage" knowledge.
         * This might make a good usb_gadget_ops hook ...
         */
-       if (gadget_is_net2280(gadget)) {
-               char name[8];
-
-               if (type == USB_ENDPOINT_XFER_INT) {
-                       /* ep-e, ep-f are PIO with only 64 byte fifos */
-                       ep = gadget_find_ep_by_name(gadget, "ep-e");
-                       if (ep && usb_gadget_ep_match_desc(gadget,
-                                       ep, desc, ep_comp))
-                               goto found_ep;
-                       ep = gadget_find_ep_by_name(gadget, "ep-f");
-                       if (ep && usb_gadget_ep_match_desc(gadget,
-                                       ep, desc, ep_comp))
-                               goto found_ep;
-               }
-
-               /* USB3380: use same address for usb and hardware endpoints */
-               snprintf(name, sizeof(name), "ep%d%s", usb_endpoint_num(desc),
-                               usb_endpoint_dir_in(desc) ? "in" : "out");
-               ep = gadget_find_ep_by_name(gadget, name);
-               if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
-                       goto found_ep;
-       } else if (gadget_is_goku (gadget)) {
+       if (gadget_is_goku(gadget)) {
                if (USB_ENDPOINT_XFER_INT == type) {
                        /* single buffering is enough */
                        ep = gadget_find_ep_by_name(gadget, "ep3-bulk");
index 872ca257cfa4aa0373c808cc76910f262bffcf24..cf0ed42f5591c93065d6d9c5741dea6967ad4829 100644 (file)
@@ -1550,6 +1550,33 @@ static int net2280_pullup(struct usb_gadget *_gadget, int is_on)
        return 0;
 }
 
+static struct usb_ep *net2280_match_ep(struct usb_gadget *_gadget,
+               struct usb_endpoint_descriptor *desc,
+               struct usb_ss_ep_comp_descriptor *ep_comp)
+{
+       char name[8];
+       struct usb_ep *ep;
+
+       if (usb_endpoint_type(desc) == USB_ENDPOINT_XFER_INT) {
+               /* ep-e, ep-f are PIO with only 64 byte fifos */
+               ep = gadget_find_ep_by_name(_gadget, "ep-e");
+               if (ep && usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp))
+                       return ep;
+               ep = gadget_find_ep_by_name(_gadget, "ep-f");
+               if (ep && usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp))
+                       return ep;
+       }
+
+       /* USB3380: use same address for usb and hardware endpoints */
+       snprintf(name, sizeof(name), "ep%d%s", usb_endpoint_num(desc),
+                       usb_endpoint_dir_in(desc) ? "in" : "out");
+       ep = gadget_find_ep_by_name(_gadget, name);
+       if (ep && usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp))
+               return ep;
+
+       return NULL;
+}
+
 static int net2280_start(struct usb_gadget *_gadget,
                struct usb_gadget_driver *driver);
 static int net2280_stop(struct usb_gadget *_gadget);
@@ -1561,6 +1588,7 @@ static const struct usb_gadget_ops net2280_ops = {
        .pullup         = net2280_pullup,
        .udc_start      = net2280_start,
        .udc_stop       = net2280_stop,
+       .match_ep       = net2280_match_ep,
 };
 
 /*-------------------------------------------------------------------------*/