[PATCH] bootstd: USB devtype detection for script boot
Simon Glass
sjg at chromium.org
Wed Jun 28 09:42:19 CEST 2023
Hi John,
On Tue, 27 Jun 2023 at 15:39, John Clark <inindev at gmail.com> wrote:
>
> Change the device type from "usb_mass_storage" to "usb" when
> booting a script.
>
> Before this change:
> => printenv devtype
> devtype=usb_mass_storage
>
> After this change:
> => printenv devtype
> devtype=usb
>
> Signed-off-by: John Clark <inindev at gmail.com>
> ---
>
> boot/bootmeth_script.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c
> index 225eb18ee6..9fdadb3005 100644
> --- a/boot/bootmeth_script.c
> +++ b/boot/bootmeth_script.c
> @@ -187,10 +187,14 @@ static int script_set_bootflow(struct udevice *dev, struct bootflow *bflow,
> static int script_boot(struct udevice *dev, struct bootflow *bflow)
> {
> struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
> + const char *devtype = blk_get_devtype(bflow->blk);
> ulong addr;
> int ret;
>
> - ret = env_set("devtype", blk_get_devtype(bflow->blk));
> + if (!strcmp("usb_mass_storage", devtype))
I only just thought of this, but I think it is better to check
blk->uclass_id == UCLASS_USB instead, since it avoids a string
comparison.
> + ret = env_set("devtype", "usb");
> + else
> + ret = env_set("devtype", devtype);
> if (!ret)
> ret = env_set_hex("devnum", desc->devnum);
> if (!ret)
> @@ -198,7 +202,7 @@ static int script_boot(struct udevice *dev, struct bootflow *bflow)
> if (!ret)
> ret = env_set("prefix", bflow->subdir);
> if (!ret && IS_ENABLED(CONFIG_ARCH_SUNXI) &&
> - !strcmp("mmc", blk_get_devtype(bflow->blk)))
> + !strcmp("mmc", devtype))
> ret = env_set_hex("mmc_bootdev", desc->devnum);
> if (ret)
> return log_msg_ret("env", ret);
> --
> 2.39.2
>
Regards,
Simon
More information about the U-Boot
mailing list