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>
This commit is contained in:
Simon Glass 2023-01-17 10:48:15 -07:00 committed by Tom Rini
parent 47aedc29dc
commit 91943ff703
7 changed files with 166 additions and 76 deletions

View file

@ -267,10 +267,13 @@ int bootdev_find_by_any(const char *name, struct udevice **devp,
/**
* bootdev_setup_iter() - Set up iteration through bootdevs
*
* This sets up the an interation, based on the priority of each bootdev, the
* bootdev-order property in the bootstd node (or the boot_targets env var).
* This sets up the an interation, based on the provided device or label. If
* neither is provided, the iteration is based on the priority of each bootdev,
* the * bootdev-order property in the bootstd node (or the boot_targets env
* var).
*
* @iter: Iterator to update with the order
* @label: label to scan, or NULL to scan all
* @devp: On entry, *devp is NULL to scan all, otherwise this is the (single)
* device to scan. Returns the first device to use, which is the passed-in
* @devp if it was non-NULL
@ -279,8 +282,8 @@ int bootdev_find_by_any(const char *name, struct udevice **devp,
* Return: 0 if OK, -ENOENT if no bootdevs, -ENOMEM if out of memory, other -ve
* on other error
*/
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);
/**
* bootdev_list_hunters() - List the available bootdev hunters