Skip to content

Commit 7814015

Browse files
SkyRzngregkh
authored andcommitted
usb: xhci: remove duplicate code of interval checking
Move duplicate code from xhci_queue_intr_tx() and xhci_queue_isoc_tx_prepare() to the check_interval() function. Signed-off-by: Alexandr Ivanov <[email protected]> Signed-off-by: Mathias Nyman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 75b040e commit 7814015

File tree

1 file changed

+21
-32
lines changed

1 file changed

+21
-32
lines changed

drivers/usb/host/xhci-ring.c

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,26 +3005,20 @@ static void giveback_first_trb(struct xhci_hcd *xhci, int slot_id,
30053005
xhci_ring_ep_doorbell(xhci, slot_id, ep_index, stream_id);
30063006
}
30073007

3008-
/*
3009-
* xHCI uses normal TRBs for both bulk and interrupt. When the interrupt
3010-
* endpoint is to be serviced, the xHC will consume (at most) one TD. A TD
3011-
* (comprised of sg list entries) can take several service intervals to
3012-
* transmit.
3013-
*/
3014-
int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3015-
struct urb *urb, int slot_id, unsigned int ep_index)
3008+
static void check_interval(struct xhci_hcd *xhci, struct urb *urb,
3009+
struct xhci_ep_ctx *ep_ctx)
30163010
{
3017-
struct xhci_ep_ctx *ep_ctx = xhci_get_ep_ctx(xhci,
3018-
xhci->devs[slot_id]->out_ctx, ep_index);
30193011
int xhci_interval;
30203012
int ep_interval;
30213013

30223014
xhci_interval = EP_INTERVAL_TO_UFRAMES(le32_to_cpu(ep_ctx->ep_info));
30233015
ep_interval = urb->interval;
3016+
30243017
/* Convert to microframes */
30253018
if (urb->dev->speed == USB_SPEED_LOW ||
30263019
urb->dev->speed == USB_SPEED_FULL)
30273020
ep_interval *= 8;
3021+
30283022
/* FIXME change this to a warning and a suggestion to use the new API
30293023
* to set the polling interval (once the API is added).
30303024
*/
@@ -3039,6 +3033,22 @@ int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
30393033
urb->dev->speed == USB_SPEED_FULL)
30403034
urb->interval /= 8;
30413035
}
3036+
}
3037+
3038+
/*
3039+
* xHCI uses normal TRBs for both bulk and interrupt. When the interrupt
3040+
* endpoint is to be serviced, the xHC will consume (at most) one TD. A TD
3041+
* (comprised of sg list entries) can take several service intervals to
3042+
* transmit.
3043+
*/
3044+
int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3045+
struct urb *urb, int slot_id, unsigned int ep_index)
3046+
{
3047+
struct xhci_ep_ctx *ep_ctx;
3048+
3049+
ep_ctx = xhci_get_ep_ctx(xhci, xhci->devs[slot_id]->out_ctx, ep_index);
3050+
check_interval(xhci, urb, ep_ctx);
3051+
30423052
return xhci_queue_bulk_tx(xhci, mem_flags, urb, slot_id, ep_index);
30433053
}
30443054

@@ -3720,8 +3730,6 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags,
37203730
struct xhci_ring *ep_ring;
37213731
struct xhci_ep_ctx *ep_ctx;
37223732
int start_frame;
3723-
int xhci_interval;
3724-
int ep_interval;
37253733
int num_tds, num_trbs, i;
37263734
int ret;
37273735
struct xhci_virt_ep *xep;
@@ -3749,26 +3757,7 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags,
37493757
* Check interval value. This should be done before we start to
37503758
* calculate the start frame value.
37513759
*/
3752-
xhci_interval = EP_INTERVAL_TO_UFRAMES(le32_to_cpu(ep_ctx->ep_info));
3753-
ep_interval = urb->interval;
3754-
/* Convert to microframes */
3755-
if (urb->dev->speed == USB_SPEED_LOW ||
3756-
urb->dev->speed == USB_SPEED_FULL)
3757-
ep_interval *= 8;
3758-
/* FIXME change this to a warning and a suggestion to use the new API
3759-
* to set the polling interval (once the API is added).
3760-
*/
3761-
if (xhci_interval != ep_interval) {
3762-
dev_dbg_ratelimited(&urb->dev->dev,
3763-
"Driver uses different interval (%d microframe%s) than xHCI (%d microframe%s)\n",
3764-
ep_interval, ep_interval == 1 ? "" : "s",
3765-
xhci_interval, xhci_interval == 1 ? "" : "s");
3766-
urb->interval = xhci_interval;
3767-
/* Convert back to frames for LS/FS devices */
3768-
if (urb->dev->speed == USB_SPEED_LOW ||
3769-
urb->dev->speed == USB_SPEED_FULL)
3770-
urb->interval /= 8;
3771-
}
3760+
check_interval(xhci, urb, ep_ctx);
37723761

37733762
/* Calculate the start frame and put it in urb->start_frame. */
37743763
if (HCC_CFC(xhci->hcc_params) && !list_empty(&ep_ring->td_list)) {

0 commit comments

Comments
 (0)