From 66e3dce78750f6fc4f6a402ce62c20ba95976dd1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 17 Jan 2023 10:48:09 -0700 Subject: bootstd: Allow hunting for a bootdev by label Add a function to hunt for a bootdev label and find the bootdev produced by the hunter (or already present). Add a few extra flags so that we can distinguish between "mmc1", "mmc" and "1" which all need to be handled differently. Signed-off-by: Simon Glass --- boot/bootdev-uclass.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'boot') diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 5ed310c554..dcaed4c269 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -442,6 +442,13 @@ int bootdev_find_by_label(const char *label, struct udevice **devp, if (!ret) { log_debug("- found %s\n", bdev->name); *devp = bdev; + + /* + * if no sequence number was provided, we must scan all + * bootdevs for this media uclass + */ + if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && seq == -1) + method_flags |= BOOTFLOW_METHF_SINGLE_UCLASS; if (method_flagsp) *method_flagsp = method_flags; return 0; @@ -458,7 +465,7 @@ int bootdev_find_by_any(const char *name, struct udevice **devp, { struct udevice *dev; int method_flags = 0; - int ret, seq; + int ret = -ENODEV, seq; char *endp; seq = simple_strtol(name, &endp, 16); @@ -480,8 +487,9 @@ int bootdev_find_by_any(const char *name, struct udevice **devp, ret); return log_msg_ret("pro", ret); } - } else { + } else if (IS_ENABLED(CONFIG_BOOTSTD_FULL)) { ret = uclass_get_device_by_seq(UCLASS_BOOTDEV, seq, &dev); + method_flags |= BOOTFLOW_METHF_SINGLE_DEV; } if (ret) { printf("Cannot find '%s' (err=%d)\n", name, ret); @@ -495,6 +503,21 @@ int bootdev_find_by_any(const char *name, struct udevice **devp, return 0; } +int bootdev_hunt_and_find_by_label(const char *label, struct udevice **devp, + int *method_flagsp) +{ + int ret; + + ret = bootdev_hunt(label, false); + if (ret) + return log_msg_ret("scn", ret); + ret = bootdev_find_by_label(label, devp, method_flagsp); + if (ret) + return log_msg_ret("fnd", ret); + + return 0; +} + static int default_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, struct bootflow *bflow) { -- cgit v1.2.1