Title says it all ... this helps avoid problems with some hardware. Please merge.
- Dave
Some USB device controllers make it easy to handle all the various ways hosts interpret the USB spec about when control-IN transfers need to send a ZLP ... they can just send one if the host asks, or start the status stage whenever the host thinks it's time. Other controllers make it hard to be forgiving in those cases.
This patch updates all the gadget drivers to explicitly set the req->zero
flag to reflect whether the USB spec says a ZLP "must" be sent by the
device. "Forgiving" drivers won't notice the change, but the others need
to see this information passed down from the gadget driver.
Signed-off-by: David Brownell <[EMAIL PROTECTED]>
--- 1.50/drivers/usb/gadget/ether.c Sun Jun 20 21:27:35 2004
+++ edited/drivers/usb/gadget/ether.c Mon Jun 21 19:18:25 2004
@@ -1597,6 +1597,8 @@
/* respond with data transfer before status phase? */
if (value >= 0) {
req->length = value;
+ req->zero = value < ctrl->wLength
+ && (value % gadget->ep0->maxpacket) == 0;
value = usb_ep_queue (gadget->ep0, req, GFP_ATOMIC);
if (value < 0) {
DEBUG (dev, "ep_queue --> %d\n", value);
--- 1.9/drivers/usb/gadget/file_storage.c Sun Jun 20 19:20:40 2004
+++ edited/drivers/usb/gadget/file_storage.c Mon Jun 21 19:18:25 2004
@@ -1465,6 +1465,8 @@
/* Respond with data/status or defer until later? */
if (rc >= 0 && rc != DELAYED_STATUS) {
fsg->ep0req->length = rc;
+ fsg->ep0req->zero = rc < ctrl->wLength
+ && (rc % gadget->ep0->maxpacket) == 0;
fsg->ep0req_name = (ctrl->bRequestType & USB_DIR_IN ?
"ep0-in" : "ep0-out");
rc = ep0_queue(fsg);
--- 1.12/drivers/usb/gadget/inode.c Wed Mar 24 11:12:23 2004
+++ edited/drivers/usb/gadget/inode.c Wed Jun 23 10:29:08 2004
@@ -1496,6 +1496,8 @@
/* proceed with data transfer and status phases? */
if (value >= 0 && dev->state != STATE_SETUP) {
req->length = value;
+ req->zero = value < ctrl->wLength
+ && (value % gadget->ep0->maxpacket) == 0;
value = usb_ep_queue (gadget->ep0, req, GFP_ATOMIC);
if (value < 0) {
DBG (dev, "ep_queue --> %d\n", value);
--- 1.10/drivers/usb/gadget/serial.c Wed Jun 16 18:59:29 2004
+++ edited/drivers/usb/gadget/serial.c Mon Jun 21 19:18:25 2004
@@ -1587,6 +1587,8 @@
/* respond with data transfer before status phase? */
if (ret >= 0) {
req->length = ret;
+ req->zero = ret < ctrl->wLength
+ && (ret % gadget->ep0->maxpacket) == 0;
ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
if (ret < 0) {
printk(KERN_ERR
--- 1.29/drivers/usb/gadget/zero.c Fri May 14 17:25:52 2004
+++ edited/drivers/usb/gadget/zero.c Wed Jun 23 10:24:51 2004
@@ -1037,6 +1037,8 @@
/* respond with data transfer before status phase? */
if (value >= 0) {
req->length = value;
+ req->zero = value < ctrl->wLength
+ && (value % gadget->ep0->maxpacket) == 0;
value = usb_ep_queue (gadget->ep0, req, GFP_ATOMIC);
if (value < 0) {
DBG (dev, "ep_queue --> %d\n", value);
