summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorFelipe Balbi <felipe.balbi@linux.intel.com>2016-05-23 14:06:07 +0300
committerFelipe Balbi <felipe.balbi@linux.intel.com>2016-06-20 12:32:41 +0300
commit0fe886cdb07aeaf75a61154f34abc8dd6860978e (patch)
treee622f5b486b13b9f7597e054b731178ce8be1db4 /drivers
parent0933df159c5c82f97c6bb811b149fa1158a26087 (diff)
usb: dwc3: gadget: single return point on generic commands
Just like we did for endpoint commands, let's use a single return point for generic commands as well. This aids readability. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/dwc3/gadget.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 42eefd7c99ef..f148b11f6e4d 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -207,6 +207,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
int dwc3_send_gadget_generic_command(struct dwc3 *dwc, unsigned cmd, u32 param)
{
u32 timeout = 500;
+ int ret = 0;
u32 reg;
trace_dwc3_gadget_generic_cmd(cmd, param);
@@ -221,22 +222,20 @@ int dwc3_send_gadget_generic_command(struct dwc3 *dwc, unsigned cmd, u32 param)
"Command Complete --> %d",
DWC3_DGCMD_STATUS(reg));
if (DWC3_DGCMD_STATUS(reg))
- return -EINVAL;
- return 0;
+ ret = -EINVAL;
+ break;
}
- /*
- * We can't sleep here, because it's also called from
- * interrupt context.
- */
- timeout--;
- if (!timeout) {
- dwc3_trace(trace_dwc3_gadget,
- "Command Timed Out");
- return -ETIMEDOUT;
- }
udelay(1);
- } while (1);
+ } while (timeout--);
+
+ if (!timeout) {
+ dwc3_trace(trace_dwc3_gadget,
+ "Command Timed Out");
+ ret = -ETIMEDOUT;
+ }
+
+ return ret;
}
static int __dwc3_gadget_wakeup(struct dwc3 *dwc);