USB: usbtest: use URB_ZERO_PACKET for BULK-OUT transfers
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Tue, 23 Aug 2011 08:44:54 +0000 (10:44 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 23 Aug 2011 16:47:39 +0000 (09:47 -0700)
Executing
| testusb -a -c 1 -t 3 -v 421 -s 2048

does not complete on the gadget side.
g_zero enqueues a 4096 bytes long buffer. The host sends 2048bytes which
is a multiple of wMaxPacketSize (either 64 or 512 bytes). The host is
done with sending data but the gadget waits for more.
Since the protocol does not include transfer-length-field sending a
terminating zero packet seems the only way out.

Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/misc/usbtest.c

index bb10846affc30b39a1f7514acf5084174cb43f37..bd715006b056c07c997445a7f31ec007b5c1ba48 100644 (file)
@@ -359,8 +359,10 @@ static int simple_io(
        urb->context = &completion;
        while (retval == 0 && iterations-- > 0) {
                init_completion(&completion);
-               if (usb_pipeout(urb->pipe))
+               if (usb_pipeout(urb->pipe)) {
                        simple_fill_buf(urb);
+                       urb->transfer_flags |= URB_ZERO_PACKET;
+               }
                retval = usb_submit_urb(urb, GFP_KERNEL);
                if (retval != 0)
                        break;