Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752728AbbHEObD (ORCPT ); Wed, 5 Aug 2015 10:31:03 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:49567 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751433AbbHEObA (ORCPT ); Wed, 5 Aug 2015 10:31:00 -0400 Date: Wed, 5 Aug 2015 10:30:54 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Robert Baldyga cc: balbi@ti.com, , , Subject: Re: [PATCH v6 4/8] usb: gadget: move find_ep() from epautoconf to gadget.h In-Reply-To: <1438776130-29716-5-git-send-email-r.baldyga@samsung.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1509 Lines: 43 On Wed, 5 Aug 2015, Robert Baldyga wrote: > Move find_ep() function to gadget.h, rename it to gadget_find_ep_by_name() > and make it static inline. It can be used in UDC drivers, especially in > 'match_ep' callback after moving chip-specific endpoint matching logic from > epautoconf to UDC drivers. > --- a/include/linux/usb/gadget.h > +++ b/include/linux/usb/gadget.h > @@ -639,6 +639,24 @@ static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev) > #define gadget_for_each_ep(tmp, gadget) \ > list_for_each_entry(tmp, &(gadget)->ep_list, ep_list) > > +/** > + * gadget_find_ep_by_name - returns ep whose name is the same as sting passed > + * in second parameter or NULL if searched endpoint not found > + * @g: controller to check for quirk > + * @name: name of searched endpoint > + */ > +static inline struct usb_ep * > +gadget_find_ep_by_name(struct usb_gadget *g, const char *name) > +{ > + struct usb_ep *ep; > + > + gadget_for_each_ep(ep, g) { > + if (!strcmp(ep->name, name)) > + return ep; > + } > + > + return NULL; > +} Minor point: Is this function short enough to be worth inlining? My general feeling has been that anything containing a nontrivial loop probably shouldn't be inlined, but I could be wrong. Alan Stern -- 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/