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 <[email protected]>
---
 drivers/usb/dwc3/gadget.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 86805e67a85c..f384ad379234 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);
-- 
2.8.3

---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to