]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
usb: xhci: move all segment re-numbering to xhci_link_rings()
authorNiklas Neronin <niklas.neronin@linux.intel.com>
Wed, 26 Jun 2024 12:48:24 +0000 (15:48 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jun 2024 14:08:05 +0000 (16:08 +0200)
This is a preparation patch for switching from custom segment list
handling to using list.h functions.

Contain all segment re-numbering in xhci_link_rings() which links two
segments lists together, and performs all necessary adjustments for
them to fit together.

No need to send segment number to xhci_alloc_segments_for_ring()
as a parameter after this.

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/20240626124835.1023046-11-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-mem.c

index 49e14ad9b754d94d2c0560bb7af408e92dfe1c01..d7654f475dafbf45f82577fed04368b4dae0f067 100644 (file)
@@ -153,7 +153,7 @@ static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring,
                ring->last_seg = last;
        }
 
-       for (seg = last; seg != ring->last_seg; seg = seg->next)
+       for (seg = ring->enq_seg; seg != ring->last_seg; seg = seg->next)
                seg->next->num = seg->num + 1;
 }
 
@@ -324,12 +324,16 @@ EXPORT_SYMBOL_GPL(xhci_initialize_ring_info);
 
 /* Allocate segments and link them for a ring */
 static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci,
-               struct xhci_segment **first, struct xhci_segment **last,
-               unsigned int num_segs, unsigned int num,
-               unsigned int cycle_state, enum xhci_ring_type type,
-               unsigned int max_packet, gfp_t flags)
+                                       struct xhci_segment **first,
+                                       struct xhci_segment **last,
+                                       unsigned int num_segs,
+                                       unsigned int cycle_state,
+                                       enum xhci_ring_type type,
+                                       unsigned int max_packet,
+                                       gfp_t flags)
 {
        struct xhci_segment *prev;
+       unsigned int num = 0;
        bool chain_links;
 
        chain_links = xhci_link_chain_quirk(xhci, type);
@@ -388,9 +392,8 @@ struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci,
        if (num_segs == 0)
                return ring;
 
-       ret = xhci_alloc_segments_for_ring(xhci, &ring->first_seg,
-                       &ring->last_seg, num_segs, 0, cycle_state, type,
-                       max_packet, flags);
+       ret = xhci_alloc_segments_for_ring(xhci, &ring->first_seg, &ring->last_seg, num_segs,
+                                          cycle_state, type, max_packet, flags);
        if (ret)
                goto fail;
 
@@ -428,10 +431,8 @@ int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring,
        struct xhci_segment     *last;
        int                     ret;
 
-       ret = xhci_alloc_segments_for_ring(xhci, &first, &last,
-                       num_new_segs, ring->enq_seg->num + 1,
-                       ring->cycle_state, ring->type,
-                       ring->bounce_buf_len, flags);
+       ret = xhci_alloc_segments_for_ring(xhci, &first, &last, num_new_segs, ring->cycle_state,
+                                          ring->type, ring->bounce_buf_len, flags);
        if (ret)
                return -ENOMEM;