usb: core: hcd: Create platform devices for onboard hubs in probe()
authorMatthias Kaehlcke <mka@chromium.org>
Thu, 17 Feb 2022 18:42:54 +0000 (10:42 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 26 Apr 2022 12:01:12 +0000 (14:01 +0200)
Call onboard_hub_create/destroy_pdevs() from usb_add/remove_hcd()
for primary HCDs to create/destroy platform devices for onboard
USB hubs that may be connected to the root hub of the controller.
These functions are a NOP unless CONFIG_USB_ONBOARD_HUB=y/m.

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

Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Link: https://lore.kernel.org/r/20220217104219.v21.3.I7a3a7d9d2126c34079b1cab87aa0b2ec3030f9b7@changeid
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/hcd.c
include/linux/usb/hcd.h

index d9712c2..8178507 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/phy/phy.h>
 #include <linux/usb.h>
 #include <linux/usb/hcd.h>
+#include <linux/usb/onboard_hub.h>
 #include <linux/usb/otg.h>
 
 #include "usb.h"
@@ -2984,6 +2985,9 @@ int usb_add_hcd(struct usb_hcd *hcd,
        if (hcd->uses_new_polling && HCD_POLL_RH(hcd))
                usb_hcd_poll_rh_status(hcd);
 
+       if (usb_hcd_is_primary_hcd(hcd))
+               onboard_hub_create_pdevs(hcd->self.root_hub, &hcd->onboard_hub_devs);
+
        return retval;
 
 err_register_root_hub:
@@ -3062,6 +3066,8 @@ void usb_remove_hcd(struct usb_hcd *hcd)
        if (usb_hcd_is_primary_hcd(hcd)) {
                if (hcd->irq > 0)
                        free_irq(hcd->irq, hcd);
+
+               onboard_hub_destroy_pdevs(&hcd->onboard_hub_devs);
        }
 
        usb_deregister_bus(&hcd->self);
index 548a028..4ebc91c 100644 (file)
@@ -198,6 +198,7 @@ struct usb_hcd {
        struct usb_hcd          *shared_hcd;
        struct usb_hcd          *primary_hcd;
 
+       struct list_head        onboard_hub_devs;
 
 #define HCD_BUFFER_POOLS       4
        struct dma_pool         *pool[HCD_BUFFER_POOLS];