aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/core/usb.c10
-rw-r--r--include/linux/usb.h2
2 files changed, 10 insertions, 2 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 020b58528d9..f026991d0bd 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -375,18 +375,24 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
*/
if (unlikely(!parent)) {
dev->devpath[0] = '0';
+ dev->route = 0;
dev->dev.parent = bus->controller;
dev_set_name(&dev->dev, "usb%d", bus->busnum);
root_hub = 1;
} else {
/* match any labeling on the hubs; it's one-based */
- if (parent->devpath[0] == '0')
+ if (parent->devpath[0] == '0') {
snprintf(dev->devpath, sizeof dev->devpath,
"%d", port1);
- else
+ /* Root ports are not counted in route string */
+ dev->route = 0;
+ } else {
snprintf(dev->devpath, sizeof dev->devpath,
"%s.%d", parent->devpath, port1);
+ dev->route = parent->route +
+ (port1 << ((parent->level - 1)*4));
+ }
dev->dev.parent = &parent->dev;
dev_set_name(&dev->dev, "%d-%s", bus->busnum, dev->devpath);
diff --git a/include/linux/usb.h b/include/linux/usb.h
index fb1f2a32ae0..2b380a16c62 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -362,6 +362,7 @@ struct usb_tt;
* struct usb_device - kernel's representation of a USB device
* @devnum: device number; address on a USB bus
* @devpath: device ID string for use in messages (e.g., /port/...)
+ * @route: tree topology hex string for use with xHCI
* @state: device state: configured, not attached, etc.
* @speed: device speed: high/full/low (or error)
* @tt: Transaction Translator info; used with low/full speed dev, highspeed hub
@@ -427,6 +428,7 @@ struct usb_tt;
struct usb_device {
int devnum;
char devpath [16];
+ u32 route;
enum usb_device_state state;
enum usb_device_speed speed;