Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753902AbbGOGiu (ORCPT ); Wed, 15 Jul 2015 02:38:50 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:36563 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753774AbbGOGiq (ORCPT ); Wed, 15 Jul 2015 02:38:46 -0400 X-AuditID: cbfee61b-f79416d0000014c0-0b-55a5fff44ed7 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 v3 46/46] usb: musb: gadget: add musb_match_ep() function Date: Wed, 15 Jul 2015 08:32:33 +0200 Message-id: <1436941953-1327-47-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1436941953-1327-1-git-send-email-r.baldyga@samsung.com> References: <1436941953-1327-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmkeLIzCtJLcpLzFFi42I5/e+xoO6X/0tDDY5fNbSY9bKdxeLg/XqL vQvuMlp03j/MbNH09xWLxZ4zv9gtmhevZ7O4sM7cYvfpS4wWvx4IWWx6fI3Vov/caRaLy7vm sFnMXtLPYrFoWSuzxe/v/1gt1h65y27x7mWExbfLzewWx2b/ZbJ4cHgnu8WsN8IOYh6Tn2xk 8ljwayuLx719h1k8+td9ZvX4d7ifyWPnrLvsHvvnrmH32Lyk3uP8jIWMHn1bVjF6bNn/mdHj +I3tTB6fN8l57P38m8Vj++7lLAH8UVw2Kak5mWWpRfp2CVwZT5vjClqlKo5sXs7awHhKtIuR k0NCwERi16JXLBC2mMSFe+vZuhi5OIQEpjNK7Lp0ignC+cko8e3uelaQKjYBHYkt3ycwgtgi QPa6vzvAOpgF1rJI3HqzAGyUsICnxMuGpWA2i4CqxNw7rWANvAKuEp0ftrNCrJOTOHlsMpjN CRSf3vOLGcQWEnCReLrrA9MERt4FjAyrGEVTC5ILipPSc430ihNzi0vz0vWS83M3MYKj6Jn0 DsZVDRaHGAU4GJV4eBsWLQ0VYk0sK67MPcQowcGsJMI7+yNQiDclsbIqtSg/vqg0J7X4EKM0 B4uSOO/JfJ9QIYH0xJLU7NTUgtQimCwTB6dUA+NytS3JYru/3Z3ZsuVSZf7x3Ekq10OX3tNh /s8fvi73Cev5tAeqG9z/RsxgcNPMmZ7vfrqkUadx98avp1Lify7cKyz85tWBDVFZT2Zod8id X/jv1kzhhJ8zqkQtv7X/UCyJCdPtPTPP+LCWSfTDlwX/w9/tl3Ge2HyqMGyf+q39y+R4o5yf XjRQYinOSDTUYi4qTgQAusawRJ4CAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3478 Lines: 105 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 --- drivers/usb/gadget/epautoconf.c | 23 ----------------------- drivers/usb/musb/musb_gadget.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index da45371..254ece7 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -83,29 +83,6 @@ struct usb_ep *usb_ep_autoconfig_ss( goto found_ep; } - /* First, apply chip-specific "best usage" knowledge. - * This might make a good usb_gadget_ops hook ... - */ -#ifdef CONFIG_BLACKFIN - if (gadget_is_musbhdrc(gadget)) { - if ((USB_ENDPOINT_XFER_BULK == type) || - (USB_ENDPOINT_XFER_ISOC == type)) { - if (USB_DIR_IN & desc->bEndpointAddress) - ep = gadget_find_ep_by_name(gadget, "ep5in"); - else - ep = gadget_find_ep_by_name(gadget, "ep6out"); - } else if (USB_ENDPOINT_XFER_INT == type) { - if (USB_DIR_IN & desc->bEndpointAddress) - ep = gadget_find_ep_by_name(gadget, "ep1in"); - else - ep = gadget_find_ep_by_name(gadget, "ep2out"); - } else - ep = NULL; - if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) - goto found_ep; - } -#endif - /* Second, look at endpoints until an unclaimed one looks usable */ list_for_each_entry (ep, &gadget->ep_list, ep_list) { if (usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 043248a..3a64cf2 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1684,6 +1684,39 @@ static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on) return 0; } +#ifdef CONFIG_BLACKFIN +static struct usb_ep *musb_match_ep(struct usb_gadget *g, + struct usb_endpoint_descriptor *desc, + struct usb_ss_ep_comp_descriptor *ep_comp) +{ + struct usb_ep *ep = NULL; + u8 type = usb_endpoint_type(desc); + + switch(type) { + case USB_ENDPOINT_XFER_ISOC: + case USB_ENDPOINT_XFER_BULK: + if (usb_endpoint_dir_in(desc)) + ep = gadget_find_ep_by_name(g, "ep5in"); + else + ep = gadget_find_ep_by_name(g, "ep6out"); + break; + case USB_ENDPOINT_XFER_INT: + if (usb_endpoint_dir_in(desc)) + ep = gadget_find_ep_by_name(g, "ep1in"); + else + ep = gadget_find_ep_by_name(g, "ep2out"); + default: + } + + if (ep && usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) + return ep; + + return NULL; +} +#else +#define musb_match_ep NULL +#endif + static int musb_gadget_start(struct usb_gadget *g, struct usb_gadget_driver *driver); static int musb_gadget_stop(struct usb_gadget *g); @@ -1697,6 +1730,7 @@ static const struct usb_gadget_ops musb_gadget_operations = { .pullup = musb_gadget_pullup, .udc_start = musb_gadget_start, .udc_stop = musb_gadget_stop, + .match_ep = musb_match_ep, }; /* ----------------------------------------------------------------------- */ -- 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/