Re: Zero-Byte Packet Questions
Alan Stern <[email protected]>
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 7 Mar 2007, Pandita, Vikram wrote: > Alan > If the peripheral driver is to decide to send a ZLP or not based on the > length of data transfer, then the API given to Gadget driver of req.zero > is redundant. Yes, it is redundant. That doesn't mean it is bad. Lots of little optimizations are redundant, and this is one of them. For example, consider that (++x) means the same thing as (x += 1). So prefix ++ is redundant. That doesn't make it bad. > My understanding is that the Gadget driver should respect the API and > set the req.zero responsibly and hence the following fix suggested in > Gadget Zero. Else the zero flag can be removed? I don't know what you mean by "responsibly". The gadget driver can set req.zero whenever it wants to. The peripheral controller driver then has to send an extra zero-length packet if and only if req.length is > 0 and is an exact multiple of the maxpacket size. What's wrong with that? > Signed-off-by: Vikram Pandita <[email protected]> > --- > diff -purN a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c > --- a/drivers/usb/gadget/zero.c 2007-02-02 18:33:34.000000000 +0530 > +++ b/drivers/usb/gadget/zero.c 2007-02-07 17:28:47.000000000 +0530 > @@ -1072,7 +1072,8 @@ unknown: > /* respond with data transfer before status phase? */ > if (value >= 0) { > req->length = value; > - req->zero = value < w_length; > + req->zero = value < w_length && > + (value % gadget->ep0->maxpacket) == 0; > value = usb_ep_queue (gadget->ep0, req, GFP_ATOMIC); > if (value < 0) { > DBG (dev, "ep_queue --> %d\n", value); This patch is bad. It adds extra code for no reason. If you think the "zero" flag should be removed, try re-writing this routine without it. You will have to add an awful lot of additional code. Alan Stern ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel