From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755430AbbHFLRQ (ORCPT ); Thu, 6 Aug 2015 07:17:16 -0400 Received: from mail-la0-f50.google.com ([209.85.215.50]:34042 "EHLO mail-la0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754686AbbHFLRO (ORCPT ); Thu, 6 Aug 2015 07:17:14 -0400 Subject: Re: [PATCH v7 6/8] usb: gadget: goku_udc: add goku_match_ep() function To: Robert Baldyga , balbi@ti.com References: <1438847923-27595-1-git-send-email-r.baldyga@samsung.com> <1438847923-27595-7-git-send-email-r.baldyga@samsung.com> Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, stern@rowland.harvard.edu From: Sergei Shtylyov Message-ID: <55C34236.5080700@cogentembedded.com> Date: Thu, 6 Aug 2015 14:17:10 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1438847923-27595-7-git-send-email-r.baldyga@samsung.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello. On 8/6/2015 10:58 AM, Robert Baldyga wrote: > 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 0ff5134..574b6a4 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; You used *switch* in the MUSB driver but not here, despite the above is also asking for *switch*. Why? :-) > + } > + > + return NULL; > +} > + MBR, Sergei