diff options
author | Simon Glass <sjg@chromium.org> | 2023-01-17 20:48:15 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-01-24 02:11:41 +0300 |
commit | 91943ff7038f9c47fb310dbc22150b5664c8fbf7 (patch) | |
tree | 34db142da2cb42b692d8589502234594ee7bc078 /boot | |
parent | 47aedc29dcb9871e076f6e4aa82004633af513ef (diff) | |
download | u-boot-91943ff7038f9c47fb310dbc22150b5664c8fbf7.tar.xz |
bootstd: Allow scanning a single bootdev label
We want to support scanning a single label, like 'mmc' or 'usb0'. Add
this feature by plumbing the label through to the iterator, setting a
flag to indicate that only siblings of the initial device should be used.
This means that scanning a bootdev by its name is not supported anymore.
That feature doesn't seem very useful in practice, so it is no great loss.
Add a test for bootdev_find_by_any() while we are here.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot')
-rw-r--r-- | boot/bootdev-uclass.c | 28 | ||||
-rw-r--r-- | boot/bootflow.c | 43 |
2 files changed, 58 insertions, 13 deletions
diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 334be7662a..522ecf38eb 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -649,10 +649,10 @@ int bootdev_next_prio(struct bootflow_iter *iter, struct udevice **devp) return 0; } -int bootdev_setup_iter(struct bootflow_iter *iter, struct udevice **devp, - int *method_flagsp) +int bootdev_setup_iter(struct bootflow_iter *iter, const char *label, + struct udevice **devp, int *method_flagsp) { - struct udevice *bootstd, *dev = *devp; + struct udevice *bootstd, *dev = NULL; bool show = iter->flags & BOOTFLOWF_SHOW; int method_flags; int ret; @@ -671,10 +671,24 @@ int bootdev_setup_iter(struct bootflow_iter *iter, struct udevice **devp, } /* Handle scanning a single device */ - if (dev) { - iter->flags |= BOOTFLOWF_SINGLE_DEV; - log_debug("Selected boodev: %s\n", dev->name); - method_flags = 0; + if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && label) { + if (iter->flags & BOOTFLOWF_HUNT) { + ret = bootdev_hunt(label, show); + if (ret) + return log_msg_ret("hun", ret); + } + ret = bootdev_find_by_any(label, &dev, &method_flags); + if (ret) + return log_msg_ret("lab", ret); + + log_debug("method_flags: %x\n", method_flags); + if (method_flags & BOOTFLOW_METHF_SINGLE_UCLASS) + iter->flags |= BOOTFLOWF_SINGLE_UCLASS; + else if (method_flags & BOOTFLOW_METHF_SINGLE_DEV) + iter->flags |= BOOTFLOWF_SINGLE_DEV; + else + iter->flags |= BOOTFLOWF_SINGLE_MEDIA; + log_debug("Selected label: %s, flags %x\n", label, iter->flags); } else { bool ok; diff --git a/boot/bootflow.c b/boot/bootflow.c index 32e2aad470..50d9c2e813 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -215,7 +215,37 @@ static int iter_incr(struct bootflow_iter *iter) dev = iter->dev; log_debug("inc_dev=%d\n", inc_dev); if (!inc_dev) { - ret = bootdev_setup_iter(iter, &dev, &method_flags); + ret = bootdev_setup_iter(iter, NULL, &dev, + &method_flags); + } else if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && + (iter->flags & BOOTFLOWF_SINGLE_UCLASS)) { + /* Move to the next bootdev in this uclass */ + uclass_find_next_device(&dev); + if (!dev) { + log_debug("finished uclass %s\n", + dev_get_uclass_name(dev)); + ret = -ENODEV; + } + } else if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && + iter->flags & BOOTFLOWF_SINGLE_MEDIA) { + log_debug("next in single\n"); + method_flags = 0; + do { + /* + * Move to the next bootdev child of this media + * device. This ensures that we cover all the + * available SCSI IDs and LUNs. + */ + device_find_next_child(&dev); + log_debug("- next %s\n", + dev ? dev->name : "(none)"); + } while (dev && device_get_uclass_id(dev) != + UCLASS_BOOTDEV); + if (!dev) { + log_debug("finished uclass %s\n", + dev_get_uclass_name(dev)); + ret = -ENODEV; + } } else { log_debug("labels %p\n", iter->labels); if (iter->labels) { @@ -294,12 +324,13 @@ static int bootflow_check(struct bootflow_iter *iter, struct bootflow *bflow) return 0; } -int bootflow_scan_bootdev(struct udevice *dev, struct bootflow_iter *iter, - int flags, struct bootflow *bflow) +int bootflow_scan_bootdev(struct udevice *dev, const char *label, + struct bootflow_iter *iter, int flags, + struct bootflow *bflow) { int ret; - if (dev) + if (dev || label) flags |= BOOTFLOWF_SKIP_GLOBAL; bootflow_iter_init(iter, flags); @@ -318,7 +349,7 @@ int bootflow_scan_bootdev(struct udevice *dev, struct bootflow_iter *iter, struct udevice *dev = NULL; int method_flags; - ret = bootdev_setup_iter(iter, &dev, &method_flags); + ret = bootdev_setup_iter(iter, label, &dev, &method_flags); if (ret) return log_msg_ret("obdev", -ENODEV); @@ -345,7 +376,7 @@ int bootflow_scan_first(struct bootflow_iter *iter, int flags, { int ret; - ret = bootflow_scan_bootdev(NULL, iter, flags, bflow); + ret = bootflow_scan_bootdev(NULL, NULL, iter, flags, bflow); if (ret) return log_msg_ret("start", ret); |