Skip to content

Commit

Permalink
usb: xhci: improve xhci_clear_command_ring()
Browse files Browse the repository at this point in the history
Remove redundant TRB cycle reset, the TRB cycle is already set to zero by
the preceding memset(), making the explicit reset unnecessary.

Clarify ring loop start point. Change the loop start from the dequeue
segment to the start segment. Both approaches achieve the same result,
but starting from the start segment makes it clearer that the entire ring
is being zeroed out.

Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20241106101459.775897-27-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Niklas Neronin authored and Greg Kroah-Hartman committed Nov 6, 2024
1 parent 34fee04 commit 36b972d
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/usb/host/xhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,10 +778,8 @@ static void xhci_clear_command_ring(struct xhci_hcd *xhci)
struct xhci_segment *seg;

ring = xhci->cmd_ring;
xhci_for_each_ring_seg(ring->deq_seg, seg) {
xhci_for_each_ring_seg(ring->first_seg, seg)
memset(seg->trbs, 0, sizeof(union xhci_trb) * (TRBS_PER_SEGMENT - 1));
seg->trbs[TRBS_PER_SEGMENT - 1].link.control &= cpu_to_le32(~TRB_CYCLE);
}

xhci_initialize_ring_info(ring);
/*
Expand Down

0 comments on commit 36b972d

Please sign in to comment.