diff mbox series

[6/6] usb: dwc3: gadget: Refactor dwc3_gadget_ep_dequeue

Message ID 17318e194eea91aca59a1965967f953a55629d1e.1583443184.git.thinhn@synopsys.com (mailing list archive)
State New, archived
Headers show
Series usb: dwc3: gadget: Misc transfer cancellation fixes | expand

Commit Message

Thinh Nguyen March 5, 2020, 9:24 p.m. UTC
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>
---
 drivers/usb/dwc3/gadget.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

Comments

Felipe Balbi March 15, 2020, 9:26 a.m. UTC | #1
Thinh Nguyen <Thinh.Nguyen@synopsys.com> writes:

> 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>

doesn't apply:

checking file drivers/usb/dwc3/gadget.c
Hunk #1 FAILED at 1555.
Hunk #2 FAILED at 1581.
2 out of 2 hunks FAILED
Thinh Nguyen March 16, 2020, 12:42 a.m. UTC | #2
Hi Felipe,

Felipe Balbi wrote:
> Thinh Nguyen <Thinh.Nguyen@synopsys.com> writes:
>
>> 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>
> doesn't apply:
>
> checking file drivers/usb/dwc3/gadget.c
> Hunk #1 FAILED at 1555.
> Hunk #2 FAILED at 1581.
> 2 out of 2 hunks FAILED
>

You'd need to pick up some dependency patches of the same series to 
avoid conflict.
"usb: dwc3: gadget: Give back staled requests"
"usb: dwc3: gadget: Remove unnecessary checks"

Seeing that you have some comments for one of them, it's probably not 
picked up. I'll resend the patches after review.

Thanks,
Thinh
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index cd00f2757cb5..39c92df6e188 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1555,19 +1555,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;
 
@@ -1581,17 +1579,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;