Message ID | 251fb41d13189f475f606a6fdffc764997ee8d61.1740499185.git.jerome.forissier@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | Uthreads | expand |
On Tue, 25 Feb 2025 at 18:35, Jerome Forissier <jerome.forissier@linaro.org> wrote: > > To prepare for the introduction of coroutines in the USB initialization > sequence, move code out of usb_init() into a new helper function: > usb_init_bus(). No functional change. > > Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> > --- > drivers/usb/host/usb-uclass.c | 88 +++++++++++++++++++---------------- > 1 file changed, 48 insertions(+), 40 deletions(-) > > diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c > index bfec303e7af..cc803241461 100644 > --- a/drivers/usb/host/usb-uclass.c > +++ b/drivers/usb/host/usb-uclass.c > @@ -287,9 +287,55 @@ static int usb_probe_companion(struct udevice *bus) > return 0; > } > > +static int controllers_initialized; > + > +static void usb_init_bus(struct udevice *bus) > +{ > + int ret; > + > + /* init low_level USB */ > + printf("Bus %s: ", bus->name); > + > + /* > + * For Sandbox, we need scan the device tree each time when we > + * start the USB stack, in order to re-create the emulated USB > + * devices and bind drivers for them before we actually do the > + * driver probe. > + * > + * For USB onboard HUB, we need to do some non-trivial init > + * like enabling a power regulator, before enumeration. > + */ > + if (IS_ENABLED(CONFIG_SANDBOX) || > + IS_ENABLED(CONFIG_USB_ONBOARD_HUB)) { > + ret = dm_scan_fdt_dev(bus); > + if (ret) { > + printf("USB device scan from fdt failed (%d)", ret); > + return; > + } > + } > + > + ret = device_probe(bus); > + if (ret == -ENODEV) { /* No such device. */ > + puts("Port not available.\n"); > + controllers_initialized++; > + return; > + } > + > + if (ret) { /* Other error. */ > + printf("probe failed, error %d\n", ret); > + return; > + } > + > + ret = usb_probe_companion(bus); > + if (ret) > + return; > + > + controllers_initialized++; > + usb_started = true; > +} > + > int usb_init(void) > { > - int controllers_initialized = 0; > struct usb_uclass_priv *uc_priv; > struct usb_bus_priv *priv; > struct udevice *bus; > @@ -305,45 +351,7 @@ int usb_init(void) > uc_priv = uclass_get_priv(uc); > > uclass_foreach_dev(bus, uc) { > - /* init low_level USB */ > - printf("Bus %s: ", bus->name); > - > - /* > - * For Sandbox, we need scan the device tree each time when we > - * start the USB stack, in order to re-create the emulated USB > - * devices and bind drivers for them before we actually do the > - * driver probe. > - * > - * For USB onboard HUB, we need to do some non-trivial init > - * like enabling a power regulator, before enumeration. > - */ > - if (IS_ENABLED(CONFIG_SANDBOX) || > - IS_ENABLED(CONFIG_USB_ONBOARD_HUB)) { > - ret = dm_scan_fdt_dev(bus); > - if (ret) { > - printf("USB device scan from fdt failed (%d)", ret); > - continue; > - } > - } > - > - ret = device_probe(bus); > - if (ret == -ENODEV) { /* No such device. */ > - puts("Port not available.\n"); > - controllers_initialized++; > - continue; > - } > - > - if (ret) { /* Other error. */ > - printf("probe failed, error %d\n", ret); > - continue; > - } > - > - ret = usb_probe_companion(bus); > - if (ret) > - continue; > - > - controllers_initialized++; > - usb_started = true; > + usb_init_bus(bus); > } > > /* > -- > 2.43.0 > Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index bfec303e7af..cc803241461 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -287,9 +287,55 @@ static int usb_probe_companion(struct udevice *bus) return 0; } +static int controllers_initialized; + +static void usb_init_bus(struct udevice *bus) +{ + int ret; + + /* init low_level USB */ + printf("Bus %s: ", bus->name); + + /* + * For Sandbox, we need scan the device tree each time when we + * start the USB stack, in order to re-create the emulated USB + * devices and bind drivers for them before we actually do the + * driver probe. + * + * For USB onboard HUB, we need to do some non-trivial init + * like enabling a power regulator, before enumeration. + */ + if (IS_ENABLED(CONFIG_SANDBOX) || + IS_ENABLED(CONFIG_USB_ONBOARD_HUB)) { + ret = dm_scan_fdt_dev(bus); + if (ret) { + printf("USB device scan from fdt failed (%d)", ret); + return; + } + } + + ret = device_probe(bus); + if (ret == -ENODEV) { /* No such device. */ + puts("Port not available.\n"); + controllers_initialized++; + return; + } + + if (ret) { /* Other error. */ + printf("probe failed, error %d\n", ret); + return; + } + + ret = usb_probe_companion(bus); + if (ret) + return; + + controllers_initialized++; + usb_started = true; +} + int usb_init(void) { - int controllers_initialized = 0; struct usb_uclass_priv *uc_priv; struct usb_bus_priv *priv; struct udevice *bus; @@ -305,45 +351,7 @@ int usb_init(void) uc_priv = uclass_get_priv(uc); uclass_foreach_dev(bus, uc) { - /* init low_level USB */ - printf("Bus %s: ", bus->name); - - /* - * For Sandbox, we need scan the device tree each time when we - * start the USB stack, in order to re-create the emulated USB - * devices and bind drivers for them before we actually do the - * driver probe. - * - * For USB onboard HUB, we need to do some non-trivial init - * like enabling a power regulator, before enumeration. - */ - if (IS_ENABLED(CONFIG_SANDBOX) || - IS_ENABLED(CONFIG_USB_ONBOARD_HUB)) { - ret = dm_scan_fdt_dev(bus); - if (ret) { - printf("USB device scan from fdt failed (%d)", ret); - continue; - } - } - - ret = device_probe(bus); - if (ret == -ENODEV) { /* No such device. */ - puts("Port not available.\n"); - controllers_initialized++; - continue; - } - - if (ret) { /* Other error. */ - printf("probe failed, error %d\n", ret); - continue; - } - - ret = usb_probe_companion(bus); - if (ret) - continue; - - controllers_initialized++; - usb_started = true; + usb_init_bus(bus); } /*
To prepare for the introduction of coroutines in the USB initialization sequence, move code out of usb_init() into a new helper function: usb_init_bus(). No functional change. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> --- drivers/usb/host/usb-uclass.c | 88 +++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 40 deletions(-)