Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: core: hub: Create platform devices for onboard hubs in hub_probe()

Call onboard_hub_create/destroy_pdevs() from hub_probe/disconnect()
to create/destroy platform devices for onboard USB hubs that may be
connected to the hub. The onboard hubs must have nodes in the
device tree.

onboard_hub_create/destroy_pdevs() are NOPs unless
CONFIG_USB_ONBOARD_HUB=y/m.

Also add a field to struct usb_hub to keep track of the onboard hub
platform devices that are owned by the hub.

Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Link: https://lore.kernel.org/r/20220630123445.v24.4.Ic9dd36078f9d803de82ca01a6700c58b8e4de27e@changeid
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Matthias Kaehlcke and committed by
Greg Kroah-Hartman
3a6bf4a0 8bc06364

+9 -1
+8 -1
drivers/usb/core/hub.c
··· 23 23 #include <linux/usb.h> 24 24 #include <linux/usbdevice_fs.h> 25 25 #include <linux/usb/hcd.h> 26 + #include <linux/usb/onboard_hub.h> 26 27 #include <linux/usb/otg.h> 27 28 #include <linux/usb/quirks.h> 28 29 #include <linux/workqueue.h> ··· 1753 1752 if (hub->quirk_disable_autosuspend) 1754 1753 usb_autopm_put_interface(intf); 1755 1754 1755 + onboard_hub_destroy_pdevs(&hub->onboard_hub_devs); 1756 + 1756 1757 kref_put(&hub->kref, hub_release); 1757 1758 } 1758 1759 ··· 1872 1869 INIT_DELAYED_WORK(&hub->leds, led_work); 1873 1870 INIT_DELAYED_WORK(&hub->init_work, NULL); 1874 1871 INIT_WORK(&hub->events, hub_event); 1872 + INIT_LIST_HEAD(&hub->onboard_hub_devs); 1875 1873 spin_lock_init(&hub->irq_urb_lock); 1876 1874 timer_setup(&hub->irq_urb_retry, hub_retry_irq_urb, 0); 1877 1875 usb_get_intf(intf); ··· 1893 1889 usb_autopm_get_interface_no_resume(intf); 1894 1890 } 1895 1891 1896 - if (hub_configure(hub, &desc->endpoint[0].desc) >= 0) 1892 + if (hub_configure(hub, &desc->endpoint[0].desc) >= 0) { 1893 + onboard_hub_create_pdevs(hdev, &hub->onboard_hub_devs); 1894 + 1897 1895 return 0; 1896 + } 1898 1897 1899 1898 hub_disconnect(intf); 1900 1899 return -ENODEV;
+1
drivers/usb/core/hub.h
··· 73 73 spinlock_t irq_urb_lock; 74 74 struct timer_list irq_urb_retry; 75 75 struct usb_port **ports; 76 + struct list_head onboard_hub_devs; 76 77 }; 77 78 78 79 /**