summaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-01-17 10:48:09 -0700
committerTom Rini <trini@konsulko.com>2023-01-23 18:11:41 -0500
commit66e3dce78750f6fc4f6a402ce62c20ba95976dd1 (patch)
treeea4d629072d737d7ddfcc88e9af34e83ca5960a9 /boot
parenteacc261178b9c8024cb8de89ee4ca6c68d80d96a (diff)
downloadu-boot-66e3dce78750f6fc4f6a402ce62c20ba95976dd1.tar.gz
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 <sjg@chromium.org>
Diffstat (limited to 'boot')
-rw-r--r--boot/bootdev-uclass.c27
1 files changed, 25 insertions, 2 deletions
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)
{