[alsa-devel] [PATCH v2 1/9] usb: core: Add a helper function to check the validity of EP type in URB

Johan Hovold johan at kernel.org
Wed Oct 11 16:58:00 CEST 2017


On Wed, Oct 11, 2017 at 04:31:07PM +0200, Takashi Iwai wrote:
> On Wed, 11 Oct 2017 16:14:55 +0200,
> Johan Hovold wrote:
> > 
> > On Wed, Oct 11, 2017 at 12:36:38PM +0200, Takashi Iwai wrote:
> > > This patch adds a new helper function to perform a sanity check of the
> > > given URB to see whether it contains a valid endpoint.  It's a light-
> > > weight version of what usb_submit_urb() does, but without the kernel
> > > warning followed by the stack trace, just returns an error code.
> > > 
> > > Especially for a driver that doesn't parse the descriptor but fills
> > > the URB with the fixed endpoint (e.g. some quirks for non-compliant
> > > devices), this kind of check is preferable at the probe phase before
> > > actually submitting the urb.
> > > 
> > > Tested-by: Andrey Konovalov <andreyknvl at google.com>
> > > Signed-off-by: Takashi Iwai <tiwai at suse.de>
> > > ---
> > > v1->v2:
> > > * Fix function name typos
> > > * Call usb_urb_ep_type_check() in usb_submit_urb(), too
> > > 
> > >  drivers/usb/core/urb.c | 30 ++++++++++++++++++++++++++----
> > >  include/linux/usb.h    |  2 ++
> > >  2 files changed, 28 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
> > > index 47903d510955..8b800e34407b 100644
> > > --- a/drivers/usb/core/urb.c
> > > +++ b/drivers/usb/core/urb.c
> > > @@ -187,6 +187,31 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb);
> > >  
> > >  /*-------------------------------------------------------------------*/
> > >  
> > > +static const int pipetypes[4] = {
> > > +	PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT
> > > +};
> > 
> > No this one is no longer used outside of usb_urb_ep_type_check().
> 
> It is used in the error message, so I kept it here.

Ah, my bad, sorry.

Johan


More information about the Alsa-devel mailing list