Skip to content

Commit

Permalink
usb: dwc3: gadget: combine return points into a single one
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
  • Loading branch information
Felipe Balbi committed Apr 18, 2016
1 parent e4875bd commit c0ca324
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/usb/dwc3/gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
}

/*
Expand All @@ -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,
Expand Down

0 comments on commit c0ca324

Please sign in to comment.