Skip to content

Commit

Permalink
usb: gadget: dummy_hcd: fix rescan logic for transfer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Igor Kotrasinski authored and Felipe Balbi committed Sep 21, 2015
1 parent 5dda5be commit e42bd6a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/usb/gadget/udc/dummy_hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1385,12 +1385,15 @@ static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb,
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);

Expand Down

0 comments on commit e42bd6a

Please sign in to comment.