From 7d0a038b130cde7265d6bbc5e148734cb127f341 Mon Sep 17 00:00:00 2001 From: John Youn Date: Thu, 19 May 2016 17:26:15 -0700 Subject: [PATCH] usb: dwc3: gadget: Account for link TRB in TRBs left The TRBs left calculation didn't account for the link TRB taking up one spot. If the trb_dequeue < trb_enqueue, then the result includes the link TRB slot so it must be adjusted. Signed-off-by: John Youn Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/gadget.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 4dea3e08f95c..3c4fd4854317 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -868,6 +868,9 @@ static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep) trbs_left = dep->trb_dequeue - dep->trb_enqueue; trbs_left %= DWC3_TRB_NUM; + if (dep->trb_dequeue < dep->trb_enqueue) + trbs_left--; + return trbs_left; } -- 2.20.1