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 <johny...@synopsys.com>
---
 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 09ced5c..2d41b86 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -882,6 +882,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.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to