Skip to content

Commit bbdd82c

Browse files
Epicuriusgregkh
authored andcommitted
usb: xhci: move all segment re-numbering to xhci_link_rings()
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 <[email protected]> Signed-off-by: Mathias Nyman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7476a22 commit bbdd82c

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

drivers/usb/host/xhci-mem.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring,
153153
ring->last_seg = last;
154154
}
155155

156-
for (seg = last; seg != ring->last_seg; seg = seg->next)
156+
for (seg = ring->enq_seg; seg != ring->last_seg; seg = seg->next)
157157
seg->next->num = seg->num + 1;
158158
}
159159

@@ -324,12 +324,16 @@ EXPORT_SYMBOL_GPL(xhci_initialize_ring_info);
324324

325325
/* Allocate segments and link them for a ring */
326326
static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci,
327-
struct xhci_segment **first, struct xhci_segment **last,
328-
unsigned int num_segs, unsigned int num,
329-
unsigned int cycle_state, enum xhci_ring_type type,
330-
unsigned int max_packet, gfp_t flags)
327+
struct xhci_segment **first,
328+
struct xhci_segment **last,
329+
unsigned int num_segs,
330+
unsigned int cycle_state,
331+
enum xhci_ring_type type,
332+
unsigned int max_packet,
333+
gfp_t flags)
331334
{
332335
struct xhci_segment *prev;
336+
unsigned int num = 0;
333337
bool chain_links;
334338

335339
chain_links = xhci_link_chain_quirk(xhci, type);
@@ -388,9 +392,8 @@ struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci,
388392
if (num_segs == 0)
389393
return ring;
390394

391-
ret = xhci_alloc_segments_for_ring(xhci, &ring->first_seg,
392-
&ring->last_seg, num_segs, 0, cycle_state, type,
393-
max_packet, flags);
395+
ret = xhci_alloc_segments_for_ring(xhci, &ring->first_seg, &ring->last_seg, num_segs,
396+
cycle_state, type, max_packet, flags);
394397
if (ret)
395398
goto fail;
396399

@@ -428,10 +431,8 @@ int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring,
428431
struct xhci_segment *last;
429432
int ret;
430433

431-
ret = xhci_alloc_segments_for_ring(xhci, &first, &last,
432-
num_new_segs, ring->enq_seg->num + 1,
433-
ring->cycle_state, ring->type,
434-
ring->bounce_buf_len, flags);
434+
ret = xhci_alloc_segments_for_ring(xhci, &first, &last, num_new_segs, ring->cycle_state,
435+
ring->type, ring->bounce_buf_len, flags);
435436
if (ret)
436437
return -ENOMEM;
437438

0 commit comments

Comments
 (0)