]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usb: dwc3: gadget: simplify dwc3_ep_prev_trb()
authorFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 11 Aug 2016 09:26:59 +0000 (12:26 +0300)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 22 Aug 2016 07:45:37 +0000 (10:45 +0300)
We always need to decrement our index by at least
one. Simplify the implementation by using a
temporary local variable and making sure that we
will always decrement one extra if tmp == 0.

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

index 18045997b593f3ccd9867eb44c806f3384122bd6..a310266abc20a1c33deebb6e7729772925437187 100644 (file)
@@ -845,12 +845,12 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
  */
 static struct dwc3_trb *dwc3_ep_prev_trb(struct dwc3_ep *dep, u8 index)
 {
-       if (!index)
-               index = DWC3_TRB_NUM - 2;
-       else
-               index = dep->trb_enqueue - 1;
+       u8 tmp = index;
+
+       if (!tmp)
+               tmp = DWC3_TRB_NUM - 1;
 
-       return &dep->trb_pool[index];
+       return &dep->trb_pool[tmp - 1];
 }
 
 static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep)