Revert "usb: dwc3: gadget: always decrement by 1"
authorJohn Youn <johnyoun@synopsys.com>
Sat, 27 Aug 2016 01:43:01 +0000 (18:43 -0700)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 5 Sep 2016 10:39:23 +0000 (13:39 +0300)
This reverts commit 6f8245b4e37c ("usb: dwc3: gadget: always decrement
by 1").

We can't always decrement this value.

We should decrement only if the calculation of free slots results in a
LINK TRB being among one of the free slots (dequeue < enqueue).

Otherwise, if the LINK TRB is not among the free slots then it should
not be decremented.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc3/gadget.c

index 7a8d3d8..122e64d 100644 (file)
@@ -884,9 +884,12 @@ static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep)
                return DWC3_TRB_NUM - 1;
        }
 
-       trbs_left = dep->trb_dequeue - dep->trb_enqueue - 1;
+       trbs_left = dep->trb_dequeue - dep->trb_enqueue;
        trbs_left &= (DWC3_TRB_NUM - 1);
 
+       if (dep->trb_dequeue < dep->trb_enqueue)
+               trbs_left--;
+
        return trbs_left;
 }