[U-Boot] [PATCH 1/2] usb: gadget: fastboot: Request status and length check in rx handler

Paul Kocialkowski contact at paulk.fr
Mon Jul 6 14:08:08 CEST 2015


Le lundi 06 juillet 2015 à 12:28 +0200, Lukasz Majewski a écrit :
> Hi Paul,
> 
> > This avoids handling requests that have an error status or no data.
> > In particular, this avoids showing unnecessary error messages when
> > the USB gadget gets disconnected (e.g. with fastboot continue) and
> > the fastboot USB gadget driver sends an error back to the host (that
> > has disconnected already).
> > 
> > Signed-off-by: Paul Kocialkowski <contact at paulk.fr>
> > ---
> >  drivers/usb/gadget/f_fastboot.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/usb/gadget/f_fastboot.c
> > b/drivers/usb/gadget/f_fastboot.c index 206b6d1..b9a9099 100644
> > --- a/drivers/usb/gadget/f_fastboot.c
> > +++ b/drivers/usb/gadget/f_fastboot.c
> > @@ -635,6 +635,9 @@ static void rx_handler_command(struct usb_ep *ep,
> > struct usb_request *req) void (*func_cb)(struct usb_ep *ep, struct
> > usb_request *req) = NULL; int i;
> >  
> > +	if (req->status != 0 || req->length == 0)
> > +		return;
> > +
> >  	for (i = 0; i < ARRAY_SIZE(cmd_dispatch_info); i++) {
> >  		if (!strcmp_l1(cmd_dispatch_info[i].cmd, cmdbuf)) {
> >  			func_cb = cmd_dispatch_info[i].cb;
> > @@ -656,9 +659,7 @@ static void rx_handler_command(struct usb_ep *ep,
> > struct usb_request *req) }
> >  	}
> >  
> > -	if (req->status == 0) {
> > -		*cmdbuf = '\0';
> > -		req->actual = 0;
> > -		usb_ep_queue(ep, req, 0);
> > -	}
> > +	*cmdbuf = '\0';
> > +	req->actual = 0;
> > +	usb_ep_queue(ep, req, 0);
> >  }
> 
> Reviewed-by: Lukasz Majewski <l.majewski at samsung.com>

Thanks!

> Let's wait for some more time before pulling this patch to u-boot-dfu
> tree. I hope that other fastboot users will also review this patch.

That would be nice, but it should only affect people using a recent
version of fastboot. I have also tested this with other (older) versions
(for which everything worked fine already).

However, I certainly haven't covered all use cases, so more testing is
indeed welcome!

-- 
Paul Kocialkowski, Replicant developer

Replicant is a fully free Android distribution running on several
devices, a free software mobile operating system putting the emphasis on
freedom and privacy/security.

Website: http://www.replicant.us/
Blog: http://blog.replicant.us/
Wiki/tracker/forums: http://redmine.replicant.us/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150706/1fe9b008/attachment.sig>


More information about the U-Boot mailing list