Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754742AbbGaOGu (ORCPT ); Fri, 31 Jul 2015 10:06:50 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:38915 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751873AbbGaOGs (ORCPT ); Fri, 31 Jul 2015 10:06:48 -0400 X-AuditID: cbfee61b-f79706d000001b96-29-55bb80f6e3ed 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 45/46] usb: gadget: goku_udc: add goku_match_ep() function Date: Fri, 31 Jul 2015 16:00:57 +0200 Message-id: <1438351258-31578-46-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: H4sIAAAAAAAAAzXRX0hTcRQH8H67d9t1tbjOfz8m+jCoB/FvCP2IsiCtGyRIMpCgdOpls7a5 Np2ZlWMaalJbDCG3ZrOppJSjuUg3bbiJkaaJQvQyZ0yGhgQ1c7qh5JTePuec7+E8HALjmXE+ USOvo5VykVTA4uCzewEya0vjEubOPOMj43objib9zWjC4gOow+/FkHb3J47Gv0TYqMVqY6GF 4dPINbsIUGSFh+yBb0ykm5/F0ZLzBQuZ+nQ4ejXwCEPR8B4TvZ3ysdGv9TK0tdTCRtOmXQZ6 2d7FRCveMTYybiQgfXSBdQFShtV3DMoSeY9Tyx+9OKUbDjGpPa+OQY0ZfWzKbX7Dpkb6mqmv z3sBZfJtA+qpYwhQDncIUJ++f2BQ3YNPWFTInk5NhKJ4Sfx1ztlqWlqjppU5BRUcyY9Ak+I1 /+7mgBtowETSYxBHQDIf9psGWYdOhgvLtn1zCB7ZD+Bmxzh+WOwAGLVuYLEUi8yEjrAexJxI ktC2tsiOhTByG4dzPZ3s2CCBLIbhLTceM06egDOjI4yYueQlGHAEscNz6fDztIEZc9x+/69t 7mCXRxbBqekZTA+4FnBkCEBaUaVQVYplp+R0Q7ZKJFPVy8XZVbUyOzh4WjB1FHidlz2AJIDg GJe0OoU8pkitapR5ACQwQSLXf9Il5HGrRY33aGVtubJeSqs8IJXABSncnHy7kEeKRXX0bZpW 0Mr/UwYRx9eASkvLJM3v6+yxc8KZ5besWaWF88pIUduqqyPDejE+bC5tEzfn7kC/JC9NtgvS TWm/c4EyUvinyXSjpCpFr/YIgk2bBf7+88EMoqdiTdt9tf2awX9OzWzA72iTy660PgiYw0e7 koqkvV1nJK0G2/HqYu1NY/3aQ+fQfU2pAFdJRHkZmFIl+gfjxsZYsAIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3516 Lines: 102 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 | 20 ++------------------ drivers/usb/gadget/udc/goku_udc.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index d41fd82..da45371 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -86,24 +86,8 @@ 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_goku (gadget)) { - if (USB_ENDPOINT_XFER_INT == type) { - /* single buffering is enough */ - ep = gadget_find_ep_by_name(gadget, "ep3-bulk"); - if (ep && usb_gadget_ep_match_desc(gadget, - ep, desc, ep_comp)) - goto found_ep; - } else if (USB_ENDPOINT_XFER_BULK == type - && (USB_DIR_IN & desc->bEndpointAddress)) { - /* DMA may be available */ - ep = gadget_find_ep_by_name(gadget, "ep2-bulk"); - if (ep && usb_gadget_ep_match_desc(gadget, - ep, desc, ep_comp)) - goto found_ep; - } - #ifdef CONFIG_BLACKFIN - } else if (gadget_is_musbhdrc(gadget)) { + if (gadget_is_musbhdrc(gadget)) { if ((USB_ENDPOINT_XFER_BULK == type) || (USB_ENDPOINT_XFER_ISOC == type)) { if (USB_DIR_IN & desc->bEndpointAddress) @@ -119,8 +103,8 @@ struct usb_ep *usb_ep_autoconfig_ss( ep = NULL; if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; -#endif } +#endif /* Second, look at endpoints until an unclaimed one looks usable */ list_for_each_entry (ep, &gadget->ep_list, ep_list) { diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c index 46b8d14..d5a93ea 100644 --- a/drivers/usb/gadget/udc/goku_udc.c +++ b/drivers/usb/gadget/udc/goku_udc.c @@ -990,6 +990,30 @@ static int goku_get_frame(struct usb_gadget *_gadget) return -EOPNOTSUPP; } +static struct usb_ep *goku_match_ep(struct usb_gadget *g, + struct usb_endpoint_descriptor *desc, + struct usb_ss_ep_comp_descriptor *ep_comp) +{ + struct goku_udc *dev = to_goku_udc(g); + struct usb_ep *ep; + u8 type = usb_endpoint_type(desc); + + if (type == USB_ENDPOINT_XFER_INT) { + /* single buffering is enough */ + ep = &dev->ep[3].ep; + if (ep && usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) + return ep; + } else if (type == USB_ENDPOINT_XFER_BULK + && usb_endpoint_dir_in(desc)) { + /* DMA may be available */ + ep = &dev->ep[2].ep; + if (ep && usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) + return ep; + } + + return NULL; +} + static int goku_udc_start(struct usb_gadget *g, struct usb_gadget_driver *driver); static int goku_udc_stop(struct usb_gadget *g); @@ -998,6 +1022,7 @@ static const struct usb_gadget_ops goku_ops = { .get_frame = goku_get_frame, .udc_start = goku_udc_start, .udc_stop = goku_udc_stop, + .match_ep = goku_match_ep, // no remote wakeup // not selfpowered }; -- 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/