The controller driver may be NULL if the controller device
is the middle device between platform device and roothub.
This middle device may not need a device driver due to all
hardware control can be at platform device driver, this
platform device is usually a dual-role USB controller device.

The benefit of using this middle device is we can keep both
controller device's private data (known as struct usb_hcd)
for USB core use, and platform device's private data for
platform driver use.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/usb/core/hub.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 6d4d36d..96621fe 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4379,6 +4379,8 @@ hub_port_init(struct usb_hub *hub, struct usb_device 
*udev, int port1,
        enum usb_device_speed   oldspeed = udev->speed;
        const char              *speed;
        int                     devnum = udev->devnum;
+       struct device_driver    *driver = udev->bus->controller->driver;
+       struct device_driver    *sysdev_driver = udev->bus->sysdev->driver;
 
        /* root hub ports have a slightly longer reset period
         * (from USB 2.0 spec, section 7.1.7.5)
@@ -4446,11 +4448,19 @@ hub_port_init(struct usb_hub *hub, struct usb_device 
*udev, int port1,
        else
                speed = usb_speed_string(udev->speed);
 
+       /*
+        * The controller driver may be NULL if the controller device
+        * is the middle device between platform device and roothub.
+        * This middle device may not need a device driver due to
+        * all hardware control can be at platform device driver, this
+        * platform device is usually a dual-role USB controller device.
+        */
        if (udev->speed < USB_SPEED_SUPER)
                dev_info(&udev->dev,
                                "%s %s USB device number %d using %s\n",
                                (udev->config) ? "reset" : "new", speed,
-                               devnum, udev->bus->controller->driver->name);
+                               devnum, driver ? driver->name :
+                               sysdev_driver->name);
 
        /* Set up TT records, if needed  */
        if (hdev->tt) {
@@ -4582,7 +4592,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device 
*udev, int port1,
                                                "%s SuperSpeed%s USB device 
number %d using %s\n",
                                                (udev->config) ? "reset" : 
"new",
                                         (udev->speed == USB_SPEED_SUPER_PLUS) 
? "Plus" : "",
-                                               devnum, 
udev->bus->controller->driver->name);
+                                        devnum, driver ? driver->name : 
sysdev_driver->name);
                        }
 
                        /* cope with hardware quirkiness:
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to