[PATCH v3 2/5] usb: onboard-hub: Use devm API do automatically free the reset GPIO
Lukasz Czechowski
lukasz.czechowski at thaumatec.com
Tue Jun 10 10:02:10 CEST 2025
The reset GPIO is obtained during driver probing by the function
devm_gpiod_get_optional, which means the GPIO will be automatically
freed when the device is removed. Because of this, explicit call
to free the reset GPIO in hub remove function is not needed.
To support the Managed device resources, the DEVRES config must
be enabled, otherwise the devres functions fall back to non-managed
variants. Set the necessary dependency to DEVRES in Kconfig.
Signed-off-by: Lukasz Czechowski <lukasz.czechowski at thaumatec.com>
---
common/usb_onboard_hub.c | 3 ---
drivers/usb/Kconfig | 1 +
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/common/usb_onboard_hub.c b/common/usb_onboard_hub.c
index 7606362a4ee6..c6379192fe8f 100644
--- a/common/usb_onboard_hub.c
+++ b/common/usb_onboard_hub.c
@@ -211,9 +211,6 @@ static int usb_onboard_hub_remove(struct udevice *dev)
struct onboard_hub *hub = dev_get_priv(dev);
int ret = 0;
- if (hub->reset_gpio)
- dm_gpio_free(hub->reset_gpio->dev, hub->reset_gpio);
-
if (hub->vdd) {
ret = regulator_set_enable_if_allowed(hub->vdd, false);
if (ret)
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 99c6649e4178..daf2240ffd92 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -112,6 +112,7 @@ config USB_KEYBOARD
config USB_ONBOARD_HUB
bool "Onboard USB hub support"
depends on DM_USB
+ select DEVRES
---help---
Say Y here if you want to support discrete onboard USB hubs that
don't require an additional control bus for initialization, but
--
2.43.0
More information about the U-Boot
mailing list