Skip to content

Commit 080e73c

Browse files
Epicuriusgregkh
authored andcommitted
usb: xhci: compact 'trb_in_td()' arguments
Pass pointer to the TD (struct xhci_td *) directly, instead of its components separately. 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 b44c0ce commit 080e73c

File tree

2 files changed

+16
-27
lines changed

2 files changed

+16
-27
lines changed

drivers/usb/host/xhci-ring.c

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,8 +1024,7 @@ static int xhci_invalidate_cancelled_tds(struct xhci_virt_ep *ep)
10241024
td->urb->stream_id);
10251025
hw_deq &= ~0xf;
10261026

1027-
if (td->cancel_status == TD_HALTED ||
1028-
trb_in_td(xhci, td->start_seg, td->first_trb, td->last_trb, hw_deq, false)) {
1027+
if (td->cancel_status == TD_HALTED || trb_in_td(xhci, td, hw_deq, false)) {
10291028
switch (td->cancel_status) {
10301029
case TD_CLEARED: /* TD is already no-op */
10311030
case TD_CLEARING_CACHE: /* set TR deq command already queued */
@@ -1082,8 +1081,7 @@ static struct xhci_td *find_halted_td(struct xhci_virt_ep *ep)
10821081
hw_deq = xhci_get_hw_deq(ep->xhci, ep->vdev, ep->ep_index, 0);
10831082
hw_deq &= ~0xf;
10841083
td = list_first_entry(&ep->ring->td_list, struct xhci_td, td_list);
1085-
if (trb_in_td(ep->xhci, td->start_seg, td->first_trb,
1086-
td->last_trb, hw_deq, false))
1084+
if (trb_in_td(ep->xhci, td, hw_deq, false))
10871085
return td;
10881086
}
10891087
return NULL;
@@ -2049,25 +2047,19 @@ static void handle_port_status(struct xhci_hcd *xhci,
20492047
}
20502048

20512049
/*
2052-
* This TD is defined by the TRBs starting at start_trb in start_seg and ending
2053-
* at end_trb, which may be in another segment. If the suspect DMA address is a
2054-
* TRB in this TD, this function returns that TRB's segment. Otherwise it
2055-
* returns 0.
2050+
* If the suspect DMA address is a TRB in this TD, this function returns that
2051+
* TRB's segment. Otherwise it returns 0.
20562052
*/
2057-
struct xhci_segment *trb_in_td(struct xhci_hcd *xhci,
2058-
struct xhci_segment *start_seg,
2059-
union xhci_trb *start_trb,
2060-
union xhci_trb *end_trb,
2061-
dma_addr_t suspect_dma,
2062-
bool debug)
2053+
struct xhci_segment *trb_in_td(struct xhci_hcd *xhci, struct xhci_td *td, dma_addr_t suspect_dma,
2054+
bool debug)
20632055
{
20642056
dma_addr_t start_dma;
20652057
dma_addr_t end_seg_dma;
20662058
dma_addr_t end_trb_dma;
20672059
struct xhci_segment *cur_seg;
20682060

2069-
start_dma = xhci_trb_virt_to_dma(start_seg, start_trb);
2070-
cur_seg = start_seg;
2061+
start_dma = xhci_trb_virt_to_dma(td->start_seg, td->first_trb);
2062+
cur_seg = td->start_seg;
20712063

20722064
do {
20732065
if (start_dma == 0)
@@ -2076,7 +2068,7 @@ struct xhci_segment *trb_in_td(struct xhci_hcd *xhci,
20762068
end_seg_dma = xhci_trb_virt_to_dma(cur_seg,
20772069
&cur_seg->trbs[TRBS_PER_SEGMENT - 1]);
20782070
/* If the end TRB isn't in this segment, this is set to 0 */
2079-
end_trb_dma = xhci_trb_virt_to_dma(cur_seg, end_trb);
2071+
end_trb_dma = xhci_trb_virt_to_dma(cur_seg, td->last_trb);
20802072

20812073
if (debug)
20822074
xhci_warn(xhci,
@@ -2110,7 +2102,7 @@ struct xhci_segment *trb_in_td(struct xhci_hcd *xhci,
21102102
}
21112103
cur_seg = cur_seg->next;
21122104
start_dma = xhci_trb_virt_to_dma(cur_seg, &cur_seg->trbs[0]);
2113-
} while (cur_seg != start_seg);
2105+
} while (cur_seg != td->start_seg);
21142106

21152107
return NULL;
21162108
}
@@ -2822,8 +2814,7 @@ static int handle_tx_event(struct xhci_hcd *xhci,
28222814
td_num--;
28232815

28242816
/* Is this a TRB in the currently executing TD? */
2825-
ep_seg = trb_in_td(xhci, td->start_seg, td->first_trb,
2826-
td->last_trb, ep_trb_dma, false);
2817+
ep_seg = trb_in_td(xhci, td, ep_trb_dma, false);
28272818

28282819
/*
28292820
* Skip the Force Stopped Event. The event_trb(event_dma) of FSE
@@ -2870,8 +2861,7 @@ static int handle_tx_event(struct xhci_hcd *xhci,
28702861
!list_is_last(&td->td_list, &ep_ring->td_list)) {
28712862
struct xhci_td *td_next = list_next_entry(td, td_list);
28722863

2873-
ep_seg = trb_in_td(xhci, td_next->start_seg, td_next->first_trb,
2874-
td_next->last_trb, ep_trb_dma, false);
2864+
ep_seg = trb_in_td(xhci, td_next, ep_trb_dma, false);
28752865
if (ep_seg) {
28762866
/* give back previous TD, start handling new */
28772867
xhci_dbg(xhci, "Missing TD completion event after mid TD error\n");
@@ -2890,8 +2880,8 @@ static int handle_tx_event(struct xhci_hcd *xhci,
28902880
"part of current TD ep_index %d "
28912881
"comp_code %u\n", ep_index,
28922882
trb_comp_code);
2893-
trb_in_td(xhci, td->start_seg, td->first_trb,
2894-
td->last_trb, ep_trb_dma, true);
2883+
trb_in_td(xhci, td, ep_trb_dma, true);
2884+
28952885
return -ESHUTDOWN;
28962886
}
28972887
}

drivers/usb/host/xhci.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,9 +1870,8 @@ int xhci_alloc_tt_info(struct xhci_hcd *xhci,
18701870

18711871
/* xHCI ring, segment, TRB, and TD functions */
18721872
dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg, union xhci_trb *trb);
1873-
struct xhci_segment *trb_in_td(struct xhci_hcd *xhci,
1874-
struct xhci_segment *start_seg, union xhci_trb *start_trb,
1875-
union xhci_trb *end_trb, dma_addr_t suspect_dma, bool debug);
1873+
struct xhci_segment *trb_in_td(struct xhci_hcd *xhci, struct xhci_td *td,
1874+
dma_addr_t suspect_dma, bool debug);
18761875
int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code);
18771876
void xhci_ring_cmd_db(struct xhci_hcd *xhci);
18781877
int xhci_queue_slot_control(struct xhci_hcd *xhci, struct xhci_command *cmd,

0 commit comments

Comments
 (0)