]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
usb: gadget: dummy_hcd: fix rescan logic for transfer
authorIgor Kotrasinski <i.kotrasinsk@samsung.com>
Tue, 15 Sep 2015 14:55:31 +0000 (16:55 +0200)
committerFelipe Balbi <balbi@ti.com>
Mon, 21 Sep 2015 19:42:36 +0000 (14:42 -0500)
transfer() schedules a rescan for transfers larger than
maxpacket, which is wrong for transfers that are multiples
of maxpacket.

Rewrite to fix and clarify packet multiple / remainder
transfer logic.

Signed-off-by: Igor Kotrasinski <i.kotrasinsk@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/udc/dummy_hcd.c

index 69a0b3fa4737078a526625d2288f2b9c5369b43b..ab7e015e2f559076f01757f0f8573b2737472aed 100644 (file)
@@ -1385,12 +1385,15 @@ top:
                        if (len == 0)
                                break;
 
-                       /* use an extra pass for the final short packet */
-                       if (len > ep->ep.maxpacket) {
-                               rescan = 1;
-                               len -= (len % ep->ep.maxpacket);
+                       /* send multiple of maxpacket first, then remainder */
+                       if (len >= ep->ep.maxpacket) {
+                               is_short = 0;
+                               if (len % ep->ep.maxpacket)
+                                       rescan = 1;
+                               len -= len % ep->ep.maxpacket;
+                       } else {
+                               is_short = 1;
                        }
-                       is_short = (len % ep->ep.maxpacket) != 0;
 
                        len = dummy_perform_transfer(urb, req, len);