From: Felipe Balbi Date: Mon, 23 May 2016 10:53:34 +0000 (+0300) Subject: UPSTREAM: usb: dwc3: gadget: loop while (timeout) X-Git-Tag: firefly_0821_release~1814 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ace9119cde4afca08ebc73c5cbf6fda72a0711a6;p=firefly-linux-kernel-4.4.55.git UPSTREAM: usb: dwc3: gadget: loop while (timeout) instead of having infinite loop and always checking timeout value as a break condition, we can just decrement timeout inside while's condition. Change-Id: I665d39e7205463f5f4439f3a6d4fdfc6e3ed67b2 Signed-off-by: Felipe Balbi Signed-off-by: Wu Liang feng (cherry picked from commit f6bb225bb3ca7988ff373c62cc298e56cae1eee5) --- diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 2ea19d211077..f81a1426de5e 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -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));