From 8987c06f46dfd192f765c738b15119850054f18b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Mon, 12 Feb 2024 10:35:12 +0100 Subject: bootdev: drop unnecessary assert on bootflow->bdev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not all flows have a device and the function already contains logic to handle this case. Fixes: eccb25cd5922 ("bootstd: Allow the bootdev to be optional in bootflows") Signed-off-by: Thomas Weißschuh --- boot/bootdev-uclass.c | 1 - 1 file changed, 1 deletion(-) (limited to 'boot/bootdev-uclass.c') diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 35afb93c0e7..0fa6dad8b11 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -39,7 +39,6 @@ int bootdev_add_bootflow(struct bootflow *bflow) struct bootflow *new; int ret; - assert(bflow->dev); ret = bootstd_get_priv(&std); if (ret) return ret; -- cgit v1.2.3 From 1132471405512619241dc879861f1b5beb95c48c Mon Sep 17 00:00:00 2001 From: Nam Cao Date: Wed, 21 Feb 2024 13:41:44 +0100 Subject: bootstd: support scanning a single partition The "bootflow" command currently doesn't support scanning a single partition. This is inconvenient in setups with multiple bootable partitions within a single disk, but only one is desired. Support scanning a single disk partition. Specifically, support the syntax: bootflow scan mmc1:4 which scans only mmc device 1, partition 4. Signed-off-by: Nam Cao --- boot/bootdev-uclass.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'boot/bootdev-uclass.c') diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 0fa6dad8b11..46815ea2fdb 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -172,8 +172,10 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk, */ iter->max_part = MAX_PART_PER_BOOTDEV; - /* If this is the whole disk, check if we have bootable partitions */ - if (!iter->part) { + if (iter->flags & BOOTFLOWIF_SINGLE_PARTITION) { + /* a particular partition was specified, scan it without checking */ + } else if (!iter->part) { + /* This is the whole disk, check if we have bootable partitions */ iter->first_bootable = part_get_bootable(desc); log_debug("checking bootable=%d\n", iter->first_bootable); } else if (allow_any_part) { @@ -710,8 +712,37 @@ int bootdev_setup_iter(struct bootflow_iter *iter, const char *label, struct udevice *bootstd, *dev = NULL; bool show = iter->flags & BOOTFLOWIF_SHOW; int method_flags; + char buf[32]; int ret; + if (label) { + const char *end = strchr(label, ':'); + + if (end) { + size_t len = (size_t)(end - label); + const char *part = end + 1; + + if (len + 1 > sizeof(buf)) { + log_err("label \"%s\" is way too long\n", label); + return -EINVAL; + } + + memcpy(buf, label, len); + buf[len] = '\0'; + label = buf; + + unsigned long tmp; + + if (strict_strtoul(part, 0, &tmp)) { + log_err("Invalid partition number: %s\n", part); + return -EINVAL; + } + + iter->flags |= BOOTFLOWIF_SINGLE_PARTITION; + iter->part = tmp; + } + } + ret = uclass_first_device_err(UCLASS_BOOTSTD, &bootstd); if (ret) { log_err("Missing bootstd device\n"); -- cgit v1.2.3