UPSTREAM: usb: dwc3: gadget: combine return points into a single one
authorFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 4 Apr 2016 06:11:51 +0000 (09:11 +0300)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 16 Aug 2016 12:48:19 +0000 (20:48 +0800)
dwc3_send_gadget_ep_cmd() had three return
points. That becomes a pain to track when we need to
debug something or if we need to add more code
before returning.

Let's combine all three return points into a single
one just by introducing a local 'ret' variable.

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

drivers/usb/dwc3/gadget.c

index bfe43b2b31b8cee01345f3a8b76626730a0e6c5e..d7667f0075dcac64001b77aac20ff6377bba6173 100644 (file)
@@ -227,6 +227,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,
        struct dwc3_ep          *dep = dwc->eps[ep];
        u32                     timeout = 500;
        u32                     reg;
+       int                     ret = -EINVAL;
 
        trace_dwc3_gadget_ep_cmd(dep, cmd, params);
 
@@ -242,8 +243,9 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,
                                        "Command Complete --> %d",
                                        DWC3_DEPCMD_STATUS(reg));
                        if (DWC3_DEPCMD_STATUS(reg))
-                               return -EINVAL;
-                       return 0;
+                               break;
+                       ret = 0;
+                       break;
                }
 
                /*
@@ -254,11 +256,14 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep,
                if (!timeout) {
                        dwc3_trace(trace_dwc3_gadget,
                                        "Command Timed Out");
-                       return -ETIMEDOUT;
+                       ret = -ETIMEDOUT;
+                       break;
                }
 
                udelay(1);
        } while (1);
+
+       return ret;
 }
 
 static dma_addr_t dwc3_trb_dma_offset(struct dwc3_ep *dep,