Commit 1bb90cf0 authored by Peter Chen's avatar Peter Chen Committed by Greg Kroah-Hartman

usb: core: hub: controller driver name may be NULL

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: default avatarPeter Chen <peter.chen@nxp.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d9241ff2
...@@ -4342,6 +4342,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, ...@@ -4342,6 +4342,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
enum usb_device_speed oldspeed = udev->speed; enum usb_device_speed oldspeed = udev->speed;
const char *speed; const char *speed;
int devnum = udev->devnum; int devnum = udev->devnum;
const char *driver_name;
/* root hub ports have a slightly longer reset period /* root hub ports have a slightly longer reset period
* (from USB 2.0 spec, section 7.1.7.5) * (from USB 2.0 spec, section 7.1.7.5)
...@@ -4409,11 +4410,23 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, ...@@ -4409,11 +4410,23 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
else else
speed = usb_speed_string(udev->speed); 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->bus->controller->driver)
driver_name = udev->bus->controller->driver->name;
else
driver_name = udev->bus->sysdev->driver->name;
if (udev->speed < USB_SPEED_SUPER) if (udev->speed < USB_SPEED_SUPER)
dev_info(&udev->dev, dev_info(&udev->dev,
"%s %s USB device number %d using %s\n", "%s %s USB device number %d using %s\n",
(udev->config) ? "reset" : "new", speed, (udev->config) ? "reset" : "new", speed,
devnum, udev->bus->controller->driver->name); devnum, driver_name);
/* Set up TT records, if needed */ /* Set up TT records, if needed */
if (hdev->tt) { if (hdev->tt) {
...@@ -4545,7 +4558,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, ...@@ -4545,7 +4558,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
"%s SuperSpeed%s USB device number %d using %s\n", "%s SuperSpeed%s USB device number %d using %s\n",
(udev->config) ? "reset" : "new", (udev->config) ? "reset" : "new",
(udev->speed == USB_SPEED_SUPER_PLUS) ? "Plus" : "", (udev->speed == USB_SPEED_SUPER_PLUS) ? "Plus" : "",
devnum, udev->bus->controller->driver->name); devnum, driver_name);
} }
/* cope with hardware quirkiness: /* cope with hardware quirkiness:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment