Skip to content

Commit

Permalink
usb: dwc3: gadget: Refactor dwc3_gadget_ep_dequeue
Browse files Browse the repository at this point in the history
The flow from function dwc3_gadget_ep_dequeue() is not easy to follow.
Refactor it for easier read. No functional change in this commit.

Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
  • Loading branch information
Thinh Nguyen authored and felipebalbi committed May 5, 2020
1 parent 8411993 commit fcd2def
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions drivers/usb/dwc3/gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -1562,19 +1562,17 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,

list_for_each_entry(r, &dep->cancelled_list, list) {
if (r == req)
goto out0;
goto out;
}

list_for_each_entry(r, &dep->pending_list, list) {
if (r == req)
break;
if (r == req) {
dwc3_gadget_giveback(dep, req, -ECONNRESET);
goto out;
}
}

if (r != req) {
list_for_each_entry(r, &dep->started_list, list) {
if (r == req)
break;
}
list_for_each_entry(r, &dep->started_list, list) {
if (r == req) {
struct dwc3_request *t;

Expand All @@ -1588,17 +1586,14 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
list_for_each_entry_safe(r, t, &dep->started_list, list)
dwc3_gadget_move_cancelled_request(r);

goto out0;
goto out;
}
dev_err(dwc->dev, "request %pK was not queued to %s\n",
request, ep->name);
ret = -EINVAL;
goto out0;
}

dwc3_gadget_giveback(dep, req, -ECONNRESET);

out0:
dev_err(dwc->dev, "request %pK was not queued to %s\n",
request, ep->name);
ret = -EINVAL;
out:
spin_unlock_irqrestore(&dwc->lock, flags);

return ret;
Expand Down

0 comments on commit fcd2def

Please sign in to comment.