diff mbox series

[3/3] usb: xhci: replace hardcoded Endpoint context masks with corresponding macros

Message ID 20250226151458.3871867-4-niklas.neronin@linux.intel.com (mailing list archive)
State New
Headers show
Series usb: xhci: improve Endpoint Context Field 0x08 macros | expand

Commit Message

Niklas Neronin Feb. 26, 2025, 3:14 p.m. UTC
The Endpoint Context Field at Offset 0x08 is defined as follows:
 - Bit 0:	Dequeue Cycle State (DCS)
 - Bits 3:1:	RsvdZ (Reserved and Zero)
 - Bits 63:4:	TR Dequeue Pointer

Replace hardcoded Endpoint context masks with their corresponding macros.

In xhci_move_dequeue_past_td() move the use of TR Dequeue Pointer mask out
of the while loop. The TR dequeue pointer does not change during the loop.

Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
---
 drivers/usb/host/xhci-ring.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 9ff5ca4d5c1c..c45eabe34772 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -657,9 +657,10 @@  static int xhci_move_dequeue_past_td(struct xhci_hcd *xhci,
 	}
 
 	hw_dequeue = xhci_get_hw_deq(xhci, dev, ep_index, stream_id);
+	new_cycle = hw_dequeue & EP_CTX_CYCLE_MASK;
+	hw_dequeue &= TR_DEQ_PTR_MASK;
 	new_seg = ep_ring->deq_seg;
 	new_deq = ep_ring->dequeue;
-	new_cycle = hw_dequeue & 0x1;
 
 	/*
 	 * We want to find the pointer, segment and cycle state of the new trb
@@ -669,7 +670,7 @@  static int xhci_move_dequeue_past_td(struct xhci_hcd *xhci,
 	 */
 	do {
 		if (!cycle_found && xhci_trb_virt_to_dma(new_seg, new_deq)
-		    == (dma_addr_t)(hw_dequeue & ~0xf)) {
+		    == (dma_addr_t)hw_dequeue) {
 			cycle_found = true;
 			if (td_last_trb_found)
 				break;
@@ -1012,7 +1013,7 @@  static int xhci_invalidate_cancelled_tds(struct xhci_virt_ep *ep)
 		 */
 		hw_deq = xhci_get_hw_deq(xhci, ep->vdev, ep->ep_index,
 					 td->urb->stream_id);
-		hw_deq &= ~0xf;
+		hw_deq &= TR_DEQ_PTR_MASK;
 
 		if (td->cancel_status == TD_HALTED || trb_in_td(xhci, td, hw_deq, false)) {
 			switch (td->cancel_status) {
@@ -1102,7 +1103,7 @@  static struct xhci_td *find_halted_td(struct xhci_virt_ep *ep)
 
 	if (!list_empty(&ep->ring->td_list)) { /* Not streams compatible */
 		hw_deq = xhci_get_hw_deq(ep->xhci, ep->vdev, ep->ep_index, 0);
-		hw_deq &= ~0xf;
+		hw_deq &= TR_DEQ_PTR_MASK;
 		td = list_first_entry(&ep->ring->td_list, struct xhci_td, td_list);
 		if (trb_in_td(ep->xhci, td, hw_deq, false))
 			return td;