usb: dwc3: gadget: avoid while(1) in run_stop()
authorFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 9 Jun 2016 13:31:34 +0000 (16:31 +0300)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 21 Jun 2016 07:38:43 +0000 (10:38 +0300)
instead of looping forever and forcing a return if
timeout reaches zero, we can just use timeout and
loop's break condition directly.

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

index b3b5df6..9b9367b 100644 (file)
@@ -1581,10 +1581,10 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)
                        if (reg & DWC3_DSTS_DEVCTRLHLT)
                                break;
                }
-               timeout--;
-               if (!timeout)
-                       return -ETIMEDOUT;
-       } while (1);
+       } while (--timeout);
+
+       if (!timeout)
+               return -ETIMEDOUT;
 
        dwc3_trace(trace_dwc3_gadget, "gadget %s data soft-%s",
                        dwc->gadget_driver