summaryrefslogtreecommitdiff
path: root/drivers/usb/host/xhci-mem.c
diff options
context:
space:
mode:
authorNiklas Neronin <niklas.neronin@intel.com>2024-02-29 17:14:32 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-03-02 22:25:27 +0300
commit74151b5349266bd1a3a8307a05449a22bf0ba9de (patch)
tree22e042979d032bbe39afcffc38e89705a13501ae /drivers/usb/host/xhci-mem.c
parent06790c19086fe8f54afcd49184916132c7a8da4e (diff)
downloadlinux-74151b5349266bd1a3a8307a05449a22bf0ba9de.tar.xz
xhci: save slot ID in struct 'xhci_port'
Slot ID is a index of a virtual device in struct 'xhci_hcd->devs[]'. Previously, to get the slot ID associated with a port, we had to loop through all devices and compare ports, which is very inefficient. Instead, the slot ID (of the device which is directly connected to the port), is added to the its corresponding 'xhci_port' struct. As a result, finding the port's device is quick and easy. Function 'xhci_find_slot_id_by_port()' is removed, as it is no longer needed. Signed-off-by: Niklas Neronin <niklas.neronin@intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20240229141438.619372-4-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/xhci-mem.c')
-rw-r--r--drivers/usb/host/xhci-mem.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 9fa68fa17ac7..c4b3e425bd19 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -907,6 +907,8 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)
if (dev->udev && dev->udev->slot_id)
dev->udev->slot_id = 0;
+ if (dev->rhub_port && dev->rhub_port->slot_id == slot_id)
+ dev->rhub_port->slot_id = 0;
kfree(xhci->devs[slot_id]);
xhci->devs[slot_id] = NULL;
}
@@ -1124,6 +1126,9 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
dev->rhub_port = xhci_find_rhub_port(xhci, udev);
if (!dev->rhub_port)
return -EINVAL;
+ /* Slot ID is set to the device directly below the root hub */
+ if (!udev->parent->parent)
+ dev->rhub_port->slot_id = udev->slot_id;
slot_ctx->dev_info2 |= cpu_to_le32(ROOT_HUB_PORT(dev->rhub_port->hw_portnum + 1));
xhci_dbg(xhci, "Slot ID %d: HW portnum %d, hcd portnum %d\n",
udev->slot_id, dev->rhub_port->hw_portnum, dev->rhub_port->hcd_portnum);