usb: dwc3: gadget: loop while (timeout)
authorFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 23 May 2016 10:53:34 +0000 (13:53 +0300)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 20 Jun 2016 09:32:40 +0000 (12:32 +0300)
instead of having infinite loop and always checking
timeout value as a break condition, we can just
decrement timeout inside while's condition.

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

index e553a7c4d7373c1c4e2dd1332e273fd1a6f8eaae..25170fd5fbd4a93ba8fc26093dda3ec5a34c79a1 100644 (file)
@@ -327,19 +327,13 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
 
                        break;
                }
+       } while (--timeout);
 
-               /*
-                * We can't sleep here, because it is also called from
-                * interrupt context.
-                */
-               timeout--;
-               if (!timeout) {
-                       dwc3_trace(trace_dwc3_gadget,
-                                       "Command Timed Out");
-                       ret = -ETIMEDOUT;
-                       break;
-               }
-       } while (1);
+       if (timeout == 0) {
+               dwc3_trace(trace_dwc3_gadget,
+                               "Command Timed Out");
+               ret = -ETIMEDOUT;
+       }
 
        if (unlikely(susphy)) {
                reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));