diff options
author | Mathias Nyman <mathias.nyman@linux.intel.com> | 2024-04-29 17:02:28 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-05-01 08:47:13 +0200 |
commit | 63a1f8454962a64746a59441687dc2401290326c (patch) | |
tree | f79bffa01d0dce747892a201e1ce46e899a280d1 /drivers/usb/host/xhci.c | |
parent | 9b780c845fb60e1c0f5ec192fee835c72142173b (diff) |
xhci: stored cached port capability values in one place
Port capability flags for USB2 ports have been cached in an
u32 xhci->ext_caps[] array long before the driver had struct xhci_port
and struct xhci_port_cap structures.
Move these cached USB2 port capability values together with the other
port capability values into struct xhci_port_cap cability structure.
This also gets rid of the cumbersome way of mapping port to USB2
capability based on portnum as each port has a pointer to its capability
structure.
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20240429140245.3955523-2-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/xhci.c')
-rw-r--r-- | drivers/usb/host/xhci.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 8579603edaff..7f07672d4110 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4511,23 +4511,14 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, * only USB2 ports extended protocol capability values are cached. * Return 1 if capability is supported */ -static int xhci_check_usb2_port_capability(struct xhci_hcd *xhci, int port, +static bool xhci_check_usb2_port_capability(struct xhci_hcd *xhci, int portnum, unsigned capability) { - u32 port_offset, port_count; - int i; + struct xhci_port *port; - for (i = 0; i < xhci->num_ext_caps; i++) { - if (xhci->ext_caps[i] & capability) { - /* port offsets starts at 1 */ - port_offset = XHCI_EXT_PORT_OFF(xhci->ext_caps[i]) - 1; - port_count = XHCI_EXT_PORT_COUNT(xhci->ext_caps[i]); - if (port >= port_offset && - port < port_offset + port_count) - return 1; - } - } - return 0; + port = xhci->usb2_rhub.ports[portnum]; + + return !!(port->port_cap->protocol_caps & capability); } static int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev) |