提交 6f17f74b 编写于 作者: P Pratyush Anand 提交者: Felipe Balbi

usb: dwc3: return error in case of run/stop timeout

Although timeout has never been experienced, still to make it
meaningful, its better to return error if it ever occurs.
Signed-off-by: NPratyush Anand <pratyush.anand@st.com>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 e274a31e
...@@ -1408,7 +1408,7 @@ static int dwc3_gadget_set_selfpowered(struct usb_gadget *g, ...@@ -1408,7 +1408,7 @@ static int dwc3_gadget_set_selfpowered(struct usb_gadget *g,
return 0; return 0;
} }
static void dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on) static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on)
{ {
u32 reg; u32 reg;
u32 timeout = 500; u32 timeout = 500;
...@@ -1440,7 +1440,7 @@ static void dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on) ...@@ -1440,7 +1440,7 @@ static void dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on)
} }
timeout--; timeout--;
if (!timeout) if (!timeout)
break; return -ETIMEDOUT;
udelay(1); udelay(1);
} while (1); } while (1);
...@@ -1448,20 +1448,23 @@ static void dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on) ...@@ -1448,20 +1448,23 @@ static void dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on)
dwc->gadget_driver dwc->gadget_driver
? dwc->gadget_driver->function : "no-function", ? dwc->gadget_driver->function : "no-function",
is_on ? "connect" : "disconnect"); is_on ? "connect" : "disconnect");
return 0;
} }
static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
{ {
struct dwc3 *dwc = gadget_to_dwc(g); struct dwc3 *dwc = gadget_to_dwc(g);
unsigned long flags; unsigned long flags;
int ret;
is_on = !!is_on; is_on = !!is_on;
spin_lock_irqsave(&dwc->lock, flags); spin_lock_irqsave(&dwc->lock, flags);
dwc3_gadget_run_stop(dwc, is_on); ret = dwc3_gadget_run_stop(dwc, is_on);
spin_unlock_irqrestore(&dwc->lock, flags); spin_unlock_irqrestore(&dwc->lock, flags);
return 0; return ret;
} }
static int dwc3_gadget_start(struct usb_gadget *g, static int dwc3_gadget_start(struct usb_gadget *g,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册