From: Igor Kotrasinski Date: Tue, 15 Sep 2015 14:55:31 +0000 (+0200) Subject: usb: gadget: dummy_hcd: fix rescan logic for transfer X-Git-Tag: Ubuntu-5.10.0-12.13~14018^2~11^2~5 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=e42bd6a54b97e2a39b5004deac66a0fcd6ebbe75;p=mirror_ubuntu-hirsute-kernel.git usb: gadget: dummy_hcd: fix rescan logic for transfer 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 Signed-off-by: Felipe Balbi --- diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c index 69a0b3fa4737..ab7e015e2f55 100644 --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c @@ -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);