Commit fcd2def6 authored by Thinh Nguyen's avatar Thinh Nguyen Committed by Felipe Balbi

usb: dwc3: gadget: Refactor dwc3_gadget_ep_dequeue

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: default avatarThinh Nguyen <thinhn@synopsys.com>
Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
parent 8411993e
...@@ -1562,19 +1562,17 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, ...@@ -1562,19 +1562,17 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
list_for_each_entry(r, &dep->cancelled_list, list) { list_for_each_entry(r, &dep->cancelled_list, list) {
if (r == req) if (r == req)
goto out0; goto out;
} }
list_for_each_entry(r, &dep->pending_list, list) { list_for_each_entry(r, &dep->pending_list, list) {
if (r == req) if (r == req) {
break; dwc3_gadget_giveback(dep, req, -ECONNRESET);
goto out;
}
} }
if (r != req) { list_for_each_entry(r, &dep->started_list, list) {
list_for_each_entry(r, &dep->started_list, list) {
if (r == req)
break;
}
if (r == req) { if (r == req) {
struct dwc3_request *t; struct dwc3_request *t;
...@@ -1588,17 +1586,14 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep, ...@@ -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) list_for_each_entry_safe(r, t, &dep->started_list, list)
dwc3_gadget_move_cancelled_request(r); 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); dev_err(dwc->dev, "request %pK was not queued to %s\n",
request, ep->name);
out0: ret = -EINVAL;
out:
spin_unlock_irqrestore(&dwc->lock, flags); spin_unlock_irqrestore(&dwc->lock, flags);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment