bootstd: Remove special-case code for boot_targets
Rather than implement this as its own case in build_order(), process the
boot_targets environment variable in the bootstd_get_bootdev_order()
function. This allows build_order() to be simplified.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index affe0d3..696efb4 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -12,7 +12,6 @@
#include <bootflow.h>
#include <bootmeth.h>
#include <bootstd.h>
-#include <env.h>
#include <fs.h>
#include <log.h>
#include <malloc.h>
@@ -504,34 +503,13 @@
const char *overflow_target = NULL;
const char *const *labels;
struct udevice *dev;
- const char *targets;
int i, ret, count;
+ bool ok;
- targets = env_get("boot_targets");
- labels = IS_ENABLED(CONFIG_BOOTSTD_FULL) ?
- bootstd_get_bootdev_order(bootstd) : NULL;
- if (targets) {
- char str[BOOT_TARGETS_MAX_LEN];
- char *target;
-
- if (strlen(targets) >= BOOT_TARGETS_MAX_LEN)
- return log_msg_ret("len", -E2BIG);
-
- /* make a copy of the string, since strok() will change it */
- strcpy(str, targets);
- for (i = 0, target = strtok(str, " "); target;
- target = strtok(NULL, " ")) {
- ret = bootdev_find_by_label(target, &dev);
- if (!ret) {
- if (i == max_count) {
- overflow_target = target;
- break;
- }
- order[i++] = dev;
- }
- }
- count = i;
- } else if (labels) {
+ labels = bootstd_get_bootdev_order(bootstd, &ok);
+ if (!ok)
+ return log_msg_ret("ord", -ENOMEM);
+ if (labels) {
int upto;
upto = 0;