UPSTREAM: 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)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 16 Aug 2016 12:48:19 +0000 (20:48 +0800)
instead of looping forever and forcing a return if
timeout reaches zero, we can just use timeout and
loop's break condition directly.

Change-Id: Ibfbe125651d117cab717c5b0b73ef534ced79a67
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Wu Liang feng <wulf@rock-chips.com>
(cherry picked from commit f2df679b6c556fd3b0b7ffafea170f1679086455)

drivers/usb/dwc3/gadget.c

index 9ccf044ebb6fa961afbe9d70755f015f39e68e09..92abd5e382fe1dc63227ba52691dbc7006db3f2c 100644 (file)
@@ -1591,10 +1591,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