usb: dwc3: gadget: always decrement by 1
authorFelipe Balbi <felipe.balbi@linux.intel.com>
Wed, 24 Aug 2016 11:40:13 +0000 (14:40 +0300)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 25 Aug 2016 09:30:27 +0000 (12:30 +0300)
We need to decrement in both cases (enq > deq and
enq < deq)

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

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