Usb port isn't assigned to any bus_type. This seems not good from Greg's comments. http://marc.info/?l=linux-usb&m=136200364929942&w=2 This patch is to register usb port to usb_bus_type. The usb port's original name is "portX". This will cause name confilct after adding usb port to usb_bus_type since the usb ports with same port num under different hub have the same name. So change the usb port's name format to "port + (hub dev name) + '.' + (port num)" for non-root hub and "port + (usb bus num) + '-' + (port num)" for root hub. ls /sys/bus/usb/devices 1-0:1.0 2-0:1.0 port1-1 port1-1.3 port2-1.2 port2-2 port4-3 1-1 2-1 port1-1.1 port1-1.4 port2-1.3 port3-1 port4-4 1-1.1 2-1:1.0 port1-1.2 port1-1.5 port2-1.4 port3-2 usb1 1-1:1.0 3-0:1.0 port1-1.2.1 port1-1.6 port2-1.5 port3-3 usb2 1-1.1:1.0 3-1 port1-1.2.2 port1-2 port2-1.6 port3-4 usb3 1-1.2 3-1:1.0 port1-1.2.3 port2-1 port2-1.7 port4-1 usb4 1-1.2:1.0 4-0:1.0 port1-1.2.4 port2-1.1 port2-1.8 port4-2 Signed-off-by: Lan Tianyu <tianyu.lan@xxxxxxxxx> --- Documentation/ABI/testing/sysfs-bus-usb | 6 +++--- drivers/usb/core/port.c | 10 +++++++++- drivers/usb/core/usb-acpi.c | 7 +++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb index c8baaf5..842e8b8 100644 --- a/Documentation/ABI/testing/sysfs-bus-usb +++ b/Documentation/ABI/testing/sysfs-bus-usb @@ -221,14 +221,14 @@ Description: The file will be present for all speeds of USB devices, and will always read "no" for USB 1.1 and USB 2.0 devices. -What: /sys/bus/usb/devices/.../(hub interface)/portX +What: /sys/bus/usb/devices/.../(hub interface)/portX-X Date: August 2012 Contact: Lan Tianyu <tianyu.lan@xxxxxxxxx> Description: - The /sys/bus/usb/devices/.../(hub interface)/portX + The /sys/bus/usb/devices/.../(hub interface)/portX-X is usb port device's sysfs directory. -What: /sys/bus/usb/devices/.../(hub interface)/portX/connect_type +What: /sys/bus/usb/devices/.../(hub interface)/portX-X/connect_type Date: January 2013 Contact: Lan Tianyu <tianyu.lan@xxxxxxxxx> Description: diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index 797f9d5..4d37984 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -155,6 +155,7 @@ struct device_type usb_port_device_type = { int usb_hub_create_port_device(struct usb_hub *hub, int port1) { struct usb_port *port_dev = NULL; + struct usb_device *hdev = hub->hdev; int retval; port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL); @@ -169,7 +170,14 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1) port_dev->dev.parent = hub->intfdev; port_dev->dev.groups = port_dev_group; port_dev->dev.type = &usb_port_device_type; - dev_set_name(&port_dev->dev, "port%d", port1); + port_dev->dev.bus = &usb_bus_type; + + if (!hdev->parent) + dev_set_name(&port_dev->dev, "port%d-%d", + hdev->bus->busnum, port1); + else + dev_set_name(&port_dev->dev, "port%s.%d", + dev_name(&hdev->dev), port1); retval = device_register(&port_dev->dev); if (retval) diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c index b6f4bad..1cc55c9 100644 --- a/drivers/usb/core/usb-acpi.c +++ b/drivers/usb/core/usb-acpi.c @@ -17,7 +17,7 @@ #include <linux/pci.h> #include <acpi/acpi_bus.h> -#include "usb.h" +#include "hub.h" /** * usb_acpi_power_manageable - check whether usb port has @@ -178,7 +178,10 @@ static int usb_acpi_find_device(struct device *dev, acpi_handle *handle) return -ENODEV; return 0; } else if (is_usb_port(dev)) { - sscanf(dev_name(dev), "port%d", &port_num); + struct usb_port *port_dev = to_usb_port(dev); + + port_num = port_dev->portnum; + /* Get the struct usb_device point of port's hub */ udev = to_usb_device(dev->parent->parent); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html