From: Niklas Neronin <niklas.neronin@linux.intel.com>
To: mathias.nyman@linux.intel.com
Cc: linux-usb@vger.kernel.org,
Niklas Neronin <niklas.neronin@linux.intel.com>
Subject: [PATCH v3 07/12] usb: xhci: rework USB3 PORTLI macros
Date: Thu, 3 Dec 2026 15:42:39 +0100 [thread overview]
Message-ID: <20261203144244.1680587-8-niklas.neronin@linux.intel.com> (raw)
In-Reply-To: <20261203144244.1680587-1-niklas.neronin@linux.intel.com>
Replace the PORT_LEC(), PORT_RX_LANES() and PORT_TX_LANES() helpers
with GENMASK() based field masks, and use FIELD_GET() to extract the
fields. Rename the lane count masks after the xHCI specification
abbreviations (RLC, TLC).
Adjust the debugfs format specifiers to %lu to match the FIELD_GET()
result type.
No functional change.
Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
---
drivers/usb/host/xhci-debugfs.c | 6 ++++--
drivers/usb/host/xhci-hub.c | 4 ++--
drivers/usb/host/xhci-port.h | 12 ++++++++----
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c
index e61ee722e2cd..8a73d3ee3481 100644
--- a/drivers/usb/host/xhci-debugfs.c
+++ b/drivers/usb/host/xhci-debugfs.c
@@ -402,8 +402,10 @@ static int xhci_portli_show(struct seq_file *s, void *unused)
/* PORTLI fields are valid if port is a USB3 or eUSB2V2 port */
if (port->rhub == &xhci->usb3_rhub)
- seq_printf(s, "0x%08x LEC=%u RLC=%u TLC=%u\n", portli,
- PORT_LEC(portli), PORT_RX_LANES(portli), PORT_TX_LANES(portli));
+ seq_printf(s, "0x%08x LEC=%lu RLC=%lu TLC=%lu\n", portli,
+ FIELD_GET(PORT_LEC_MASK, portli),
+ FIELD_GET(PORT_RLC_MASK, portli),
+ FIELD_GET(PORT_TLC_MASK, portli));
else if (xhci->hcc_params2 & HCC2_E2V2C)
seq_printf(s, "0x%08x RDR=%u TDR=%u\n", portli,
PORTLI_RDR(portli), PORTLI_TDR(portli));
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 2b0522efc29a..5de1ea5d5454 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -1013,8 +1013,8 @@ static u32 xhci_get_ext_port_status(u32 portsc, u32 port_li)
ext_stat |= speed_id; /* bits 3:0, RX speed id */
ext_stat |= speed_id << 4; /* bits 7:4, TX speed id */
- ext_stat |= PORT_RX_LANES(port_li) << 8; /* bits 11:8 Rx lane count */
- ext_stat |= PORT_TX_LANES(port_li) << 12; /* bits 15:12 Tx lane count */
+ ext_stat |= FIELD_GET(PORT_RLC_MASK, port_li) << 8; /* bits 11:8 Rx lane count */
+ ext_stat |= FIELD_GET(PORT_TLC_MASK, port_li) << 12; /* bits 15:12 Tx lane count */
return ext_stat;
}
diff --git a/drivers/usb/host/xhci-port.h b/drivers/usb/host/xhci-port.h
index d6af7b878586..23986b8ed36d 100644
--- a/drivers/usb/host/xhci-port.h
+++ b/drivers/usb/host/xhci-port.h
@@ -149,10 +149,14 @@
/* bits 31:28 - Port Test Control */
#define PORT_TEST_MODE_MASK GENMASK(31, 28)
-/* USB3 Protocol PORTLI Port Link Information */
-#define PORT_LEC(p) ((p) & 0xffff)
-#define PORT_RX_LANES(p) (((p) >> 16) & 0xf)
-#define PORT_TX_LANES(p) (((p) >> 20) & 0xf)
+/* USB3 Port Link Info Register (PORTLI) 5.4.10.1 */
+/* bits 15:0 - Link Error Count */
+#define PORT_LEC_MASK GENMASK(15, 0)
+/* bits 19:16 - Rx Lane Count */
+#define PORT_RLC_MASK GENMASK(19, 16)
+/* bits 23:20 - Tx Lane Count */
+#define PORT_TLC_MASK GENMASK(23, 20)
+/* bits 31:24 - RsvdP */
/* eUSB2v2 protocol PORTLI Port Link information, RsvdP for normal USB2 */
#define PORTLI_RDR(p) ((p) & 0xf)
--
2.50.1
next prev parent reply other threads:[~2026-12-03 14:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 14:42 [PATCH v3 00/12] usb: xhci: rework xHCI Port macros Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 01/12] usb: xhci: use BIT() for single bit port register flags Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 02/12] usb: xhci: rework Port Speed macros Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 03/12] usb: xhci: rework Port Link State macros Niklas Neronin
2026-12-03 14:59 ` sashiko-bot
2026-12-03 14:42 ` [PATCH v3 04/12] usb: xhci: rework Port Indicator Control macro Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 05/12] usb: xhci: rework USB3 PORTPMSC macros Niklas Neronin
2026-12-03 14:50 ` sashiko-bot
2026-12-03 14:42 ` [PATCH v3 06/12] usb: xhci: rework USB2 " Niklas Neronin
2026-12-03 14:42 ` Niklas Neronin [this message]
2026-12-03 14:42 ` [PATCH v3 08/12] usb: xhci: rework USB2 PORTLI macros Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 09/12] usb: xhci: document USB3 PORTHLPMC register layout Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 10/12] usb: xhci: rework USB2 PORTHLPMC macros Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 11/12] usb: xhci: update port register bitfield comments for consistency Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 12/12] usb: xhci: rename PORTSC field macros to xHCI spec abbreviations Niklas Neronin
2026-12-03 14:54 ` sashiko-bot
2026-12-03 14:59 ` [PATCH v3 00/12] usb: xhci: rework xHCI Port macros sashiko-bot
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=20261203144244.1680587-8-niklas.neronin@linux.intel.com \
--to=niklas.neronin@linux.intel.com \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@linux.intel.com \
/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.