Linux USB
 help / color / mirror / Atom feed
* [PATCH] USB: Use EHCI control transfer pid macros instead of constant values.
@ 2024-03-07 17:31 Dingyan Li
  2024-03-07 18:42 ` Alan Stern
  0 siblings, 1 reply; 9+ messages in thread
From: Dingyan Li @ 2024-03-07 17:31 UTC (permalink / raw)
  To: stern, gregkh; +Cc: linux-usb, linux-kernel

Macros with good names offer better readability. Besides, also move
the definition to ehci.h.

Signed-off-by: Dingyan Li <18500469033@163.com>
---
 drivers/usb/host/ehci-q.c | 10 +++-------
 drivers/usb/host/ehci.h   |  8 +++++++-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 666f5c4db25a..51b46001e344 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -27,10 +27,6 @@
 
 /*-------------------------------------------------------------------------*/
 
-/* PID Codes that are used here, from EHCI specification, Table 3-16. */
-#define PID_CODE_IN    1
-#define PID_CODE_SETUP 2
-
 /* fill a qtd, returning how much of the buffer we were able to queue up */
 
 static unsigned int
@@ -230,7 +226,7 @@ static int qtd_copy_status (
 			/* fs/ls interrupt xfer missed the complete-split */
 			status = -EPROTO;
 		} else if (token & QTD_STS_DBE) {
-			status = (QTD_PID (token) == 1) /* IN ? */
+			status = (QTD_PID(token) == PID_CODE_IN) /* IN ? */
 				? -ENOSR  /* hc couldn't read data */
 				: -ECOMM; /* hc couldn't write data */
 		} else if (token & QTD_STS_XACT) {
@@ -606,7 +602,7 @@ qh_urb_transaction (
 		/* SETUP pid */
 		qtd_fill(ehci, qtd, urb->setup_dma,
 				sizeof (struct usb_ctrlrequest),
-				token | (2 /* "setup" */ << 8), 8);
+				token | (PID_CODE_SETUP << 8), 8);
 
 		/* ... and always at least one more pid */
 		token ^= QTD_TOGGLE;
@@ -642,7 +638,7 @@ qh_urb_transaction (
 	}
 
 	if (is_input)
-		token |= (1 /* "in" */ << 8);
+		token |= (PID_CODE_IN << 8);
 	/* else it's already initted to "out" pid (0 << 8) */
 
 	maxpacket = usb_endpoint_maxp(&urb->ep->desc);
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 1441e3400796..dafa6628e134 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -321,10 +321,16 @@ struct ehci_qtd {
 	size_t			length;			/* length of buffer */
 } __aligned(32);
 
+/* PID Codes that are used here, from EHCI specification, Table 3-16. */
+/* #define PID_CODE_OUT   0 */
+#define PID_CODE_IN    1
+#define PID_CODE_SETUP 2
+
 /* mask NakCnt+T in qh->hw_alt_next */
 #define QTD_MASK(ehci)	cpu_to_hc32(ehci, ~0x1f)
 
-#define IS_SHORT_READ(token) (QTD_LENGTH(token) != 0 && QTD_PID(token) == 1)
+#define IS_SHORT_READ(token) (QTD_LENGTH(token) != 0 && \
+						QTD_PID(token) == PID_CODE_IN)
 
 /*-------------------------------------------------------------------------*/
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-03-16  5:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-07 17:31 [PATCH] USB: Use EHCI control transfer pid macros instead of constant values Dingyan Li
2024-03-07 18:42 ` Alan Stern
2024-03-08  1:08   ` [PATCH v2] " Dingyan Li
2024-03-08  7:55     ` Greg KH
2024-03-08 20:34     ` Alan Stern
2024-03-09  3:37       ` Dingyan Li
2024-03-09  7:14         ` Greg KH
2024-03-09  9:18           ` [PATCH v3] " Dingyan Li
2024-03-16  5:35           ` Re:Re: [PATCH v2] " Dingyan Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox