All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: USB list <linux-usb@vger.kernel.org>
Subject: USB: UDC: net22{80,72}: remove mistaken test of req->zero
Date: Mon, 15 Apr 2019 13:35:46 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.1904151333280.1575-100000@iolanthe.rowland.org> (raw)

The net2280 UDC driver (and also net2272, probably via copy-and-paste)
incorrectly checks the req->zero flag during OUT transfers, after
copying data from the UDC's FIFO into memory.  This makes no sense at
all; the "zero" flag indicates that an extra zero-length packet should
be appended to an IN transfer if the length is an even multiple of the
maxpacket size.  It has nothing to do with OUT transfers.

In practice this doesn't cause any problems because gadget drivers
never set req->zero for OUT transfers anyway.  Still, it is an error
and unnecessary code, so this patch removes the check.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
---


[as1887]


 drivers/usb/gadget/udc/net2272.c |    3 +--
 drivers/usb/gadget/udc/net2280.c |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

Index: usb-devel/drivers/usb/gadget/udc/net2280.c
===================================================================
--- usb-devel.orig/drivers/usb/gadget/udc/net2280.c
+++ usb-devel/drivers/usb/gadget/udc/net2280.c
@@ -789,8 +789,7 @@ static int read_fifo(struct net2280_ep *
 		(void) readl(&ep->regs->ep_rsp);
 	}
 
-	return is_short || ((req->req.actual == req->req.length) &&
-			!req->req.zero);
+	return is_short || req->req.actual == req->req.length;
 }
 
 /* fill out dma descriptor to match a given request */
Index: usb-devel/drivers/usb/gadget/udc/net2272.c
===================================================================
--- usb-devel.orig/drivers/usb/gadget/udc/net2272.c
+++ usb-devel/drivers/usb/gadget/udc/net2272.c
@@ -573,8 +573,7 @@ net2272_read_fifo(struct net2272_ep *ep,
 
 		/* completion */
 		if (unlikely(cleanup || is_short ||
-				((req->req.actual == req->req.length)
-				 && !req->req.zero))) {
+				req->req.actual == req->req.length)) {
 
 			if (cleanup) {
 				net2272_out_flush(ep);

WARNING: multiple messages have this Message-ID (diff)
From: Alan Stern <stern@rowland.harvard.edu>
To: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: USB list <linux-usb@vger.kernel.org>
Subject: [PATCH] USB: UDC: net22{80,72}: remove mistaken test of req->zero
Date: Mon, 15 Apr 2019 13:35:46 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.1904151333280.1575-100000@iolanthe.rowland.org> (raw)
Message-ID: <20190415173546.aqgpO4mPDQlr8mKWBS4o2y6TxiFkj_dT96Ovim2KyHo@z> (raw)

The net2280 UDC driver (and also net2272, probably via copy-and-paste)
incorrectly checks the req->zero flag during OUT transfers, after
copying data from the UDC's FIFO into memory.  This makes no sense at
all; the "zero" flag indicates that an extra zero-length packet should
be appended to an IN transfer if the length is an even multiple of the
maxpacket size.  It has nothing to do with OUT transfers.

In practice this doesn't cause any problems because gadget drivers
never set req->zero for OUT transfers anyway.  Still, it is an error
and unnecessary code, so this patch removes the check.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

---


[as1887]


 drivers/usb/gadget/udc/net2272.c |    3 +--
 drivers/usb/gadget/udc/net2280.c |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

Index: usb-devel/drivers/usb/gadget/udc/net2280.c
===================================================================
--- usb-devel.orig/drivers/usb/gadget/udc/net2280.c
+++ usb-devel/drivers/usb/gadget/udc/net2280.c
@@ -789,8 +789,7 @@ static int read_fifo(struct net2280_ep *
 		(void) readl(&ep->regs->ep_rsp);
 	}
 
-	return is_short || ((req->req.actual == req->req.length) &&
-			!req->req.zero);
+	return is_short || req->req.actual == req->req.length;
 }
 
 /* fill out dma descriptor to match a given request */
Index: usb-devel/drivers/usb/gadget/udc/net2272.c
===================================================================
--- usb-devel.orig/drivers/usb/gadget/udc/net2272.c
+++ usb-devel/drivers/usb/gadget/udc/net2272.c
@@ -573,8 +573,7 @@ net2272_read_fifo(struct net2272_ep *ep,
 
 		/* completion */
 		if (unlikely(cleanup || is_short ||
-				((req->req.actual == req->req.length)
-				 && !req->req.zero))) {
+				req->req.actual == req->req.length)) {
 
 			if (cleanup) {
 				net2272_out_flush(ep);


             reply	other threads:[~2019-04-15 17:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-15 17:35 Alan Stern [this message]
2019-04-15 17:35 ` [PATCH] USB: UDC: net22{80,72}: remove mistaken test of req->zero Alan Stern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44L0.1904151333280.1575-100000@iolanthe.rowland.org \
    --to=stern@rowland.harvard.edu \
    --cc=felipe.balbi@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.