Skip to content

Commit

Permalink
usb: gadget: dummy_hcd: in transfer(), return data sent, not limit
Browse files Browse the repository at this point in the history
dummy_timer uses transfer() to update transfer limit. However,
limit passed to dummy_timer changes depending on transfer type,
so the actual limit is overwritten.

This can cause unpredictably slow / fast bulk transfers when
coupled with control / interrupt transfers.

Fix by returning actual amount of data sent in transfer() and
substracting from total.

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 e42bd6a commit 9a9ce1d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/usb/gadget/udc/dummy_hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,7 @@ static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb,
{
struct dummy *dum = dum_hcd->dum;
struct dummy_request *req;
int sent = 0;

top:
/* if there's no request queued, the device is NAKing; return */
Expand Down Expand Up @@ -1402,6 +1403,7 @@ static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb,
req->req.status = len;
} else {
limit -= len;
sent += len;
urb->actual_length += len;
req->req.actual += len;
}
Expand Down Expand Up @@ -1472,7 +1474,7 @@ static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb,
if (rescan)
goto top;
}
return limit;
return sent;
}

static int periodic_bytes(struct dummy *dum, struct dummy_ep *ep)
Expand Down Expand Up @@ -1902,7 +1904,7 @@ static void dummy_timer(unsigned long _dum_hcd)
default:
treat_control_like_bulk:
ep->last_io = jiffies;
total = transfer(dum_hcd, urb, ep, limit, &status);
total -= transfer(dum_hcd, urb, ep, limit, &status);
break;
}

Expand Down

0 comments on commit 9a9ce1d

Please sign in to comment.