[Concept,10/15] boot: Only run global bootmeths once each

Message ID 20250930005137.3650600-11-sjg@u-boot.org
State New
Headers
Series boot: Support priority for global bootmeths |

Commit Message

Simon Glass Sept. 30, 2025, 12:51 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

Use the methods_done flags to make sure that each global bootmeth is
only used once. For now this has no effect, since they are all processed
at the start.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 boot/bootflow.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
  

Patch

diff --git a/boot/bootflow.c b/boot/bootflow.c
index 51e6ad6dd86..d6c396e3087 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -354,7 +354,13 @@  static int iter_incr(struct bootflow_iter *iter)
 	}
 
 	/* Get the next boothmethod */
-	if (++iter->cur_method < iter->num_methods) {
+	for (iter->cur_method++; iter->cur_method < iter->num_methods;
+	     iter->cur_method++) {
+		/* loop until we find a global bootmeth we haven't used */
+		if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && iter->doing_global &&
+		    !bootmeth_glob_allowed(iter, iter->cur_method))
+			continue;
+
 		iter->method = iter->method_order[iter->cur_method];
 		log_debug("-> next method '%s'\n", iter->method->name);
 		return 0;