[Concept,01/15] boot: Improve comments related to global bootmeths

Message ID 20250930005137.3650600-2-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>

Add a few comments about global bootmeths and first_glob_method

Fix a broken line in bootmeth_setup_iter_order() while we are here.

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

 boot/bootflow.c        | 3 ++-
 boot/bootmeth-uclass.c | 4 ++--
 include/bootflow.h     | 3 ++-
 test/boot/bootflow.c   | 2 +-
 4 files changed, 7 insertions(+), 5 deletions(-)
  

Comments

Heinrich Schuchardt Sept. 30, 2025, 1:12 a.m. UTC | #1
Am 30. September 2025 02:51:17 MESZ schrieb Simon Glass <sjg@u-boot.org>:
>From: Simon Glass <sjg@chromium.org>
>
>Add a few comments about global bootmeths and first_glob_method
>
>Fix a broken line in bootmeth_setup_iter_order() while we are here.
>
>Signed-off-by: Simon Glass <sjg@chromium.org>

LGTM

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>


>---
>
> boot/bootflow.c        | 3 ++-
> boot/bootmeth-uclass.c | 4 ++--
> include/bootflow.h     | 3 ++-
> test/boot/bootflow.c   | 2 +-
> 4 files changed, 7 insertions(+), 5 deletions(-)
>
>diff --git a/boot/bootflow.c b/boot/bootflow.c
>index c8391641001..de1f0c99916 100644
>--- a/boot/bootflow.c
>+++ b/boot/bootflow.c
>@@ -150,7 +150,7 @@ static void bootflow_iter_set_dev(struct bootflow_iter *iter,
> 			if (dev)
> 				printf("Scanning bootdev '%s':\n", dev->name);
> 			else if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) &&
>-				ucp->flags & BOOTMETHF_GLOBAL)
>+				 ucp->flags & BOOTMETHF_GLOBAL)
> 				printf("Scanning global bootmeth '%s':\n",
> 				iter->method->name);
> 			else
>@@ -347,6 +347,7 @@ static int bootflow_check(struct bootflow_iter *iter, struct bootflow *bflow)
> 	struct udevice *dev;
> 	int ret;
> 
>+	/* handle global bootmeths if needed */
> 	if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && iter->doing_global) {
> 		bootflow_iter_set_dev(iter, NULL, 0);
> 		ret = bootmeth_get_bootflow(iter->method, bflow);
>diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c
>index 8c191082cf3..152c334f205 100644
>--- a/boot/bootmeth-uclass.c
>+++ b/boot/bootmeth-uclass.c
>@@ -147,8 +147,7 @@ int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global)
> 				bool is_global;
> 
> 				ucp = dev_get_uclass_plat(dev);
>-				is_global = ucp->flags &
>-					BOOTMETHF_GLOBAL;
>+				is_global = ucp->flags & BOOTMETHF_GLOBAL;
> 				if (is_global) {
> 					iter->first_glob_method = i;
> 					break;
>@@ -193,6 +192,7 @@ int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global)
> 	if (!count)
> 		return log_msg_ret("count2", -ENOENT);
> 
>+	/* start with the global bootmeths */
> 	if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && include_global &&
> 	    iter->first_glob_method != -1 && iter->first_glob_method != count) {
> 		iter->cur_method = iter->first_glob_method;
>diff --git a/include/bootflow.h b/include/bootflow.h
>index 284c23c59dd..4d1f888a5a8 100644
>--- a/include/bootflow.h
>+++ b/include/bootflow.h
>@@ -263,7 +263,8 @@ enum bootflow_meth_flags_t {
>  * @cur_label: Current label being processed
>  * @num_methods: Number of bootmeth devices in @method_order
>  * @cur_method: Current method number, an index into @method_order
>- * @first_glob_method: First global method, if any, else -1
>+ * @first_glob_method: Index of first global method within @method_order[], if
>+ * any, else -1
>  * @cur_prio: Current priority being scanned
>  * @method_order: List of bootmeth devices to use, in order. The normal methods
>  *	appear first, then the global ones, if any
>diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
>index 14e3326a08f..be85032985d 100644
>--- a/test/boot/bootflow.c
>+++ b/test/boot/bootflow.c
>@@ -439,7 +439,7 @@ static int bootflow_system(struct unit_test_state *uts)
> 	ut_assertok(device_probe(dev));
> 	sandbox_set_fake_efi_mgr_dev(dev, true);
> 
>-	/* We should get a single 'bootmgr' method right at the end */
>+	/* We should get a single 'bootmgr' method at the start */
> 	bootstd_clear_glob();
> 	ut_assertok(run_command("bootflow scan -lH", 0));
> 	ut_assert_skip_to_line(
  

Patch

diff --git a/boot/bootflow.c b/boot/bootflow.c
index c8391641001..de1f0c99916 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -150,7 +150,7 @@  static void bootflow_iter_set_dev(struct bootflow_iter *iter,
 			if (dev)
 				printf("Scanning bootdev '%s':\n", dev->name);
 			else if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) &&
-				ucp->flags & BOOTMETHF_GLOBAL)
+				 ucp->flags & BOOTMETHF_GLOBAL)
 				printf("Scanning global bootmeth '%s':\n",
 				iter->method->name);
 			else
@@ -347,6 +347,7 @@  static int bootflow_check(struct bootflow_iter *iter, struct bootflow *bflow)
 	struct udevice *dev;
 	int ret;
 
+	/* handle global bootmeths if needed */
 	if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && iter->doing_global) {
 		bootflow_iter_set_dev(iter, NULL, 0);
 		ret = bootmeth_get_bootflow(iter->method, bflow);
diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c
index 8c191082cf3..152c334f205 100644
--- a/boot/bootmeth-uclass.c
+++ b/boot/bootmeth-uclass.c
@@ -147,8 +147,7 @@  int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global)
 				bool is_global;
 
 				ucp = dev_get_uclass_plat(dev);
-				is_global = ucp->flags &
-					BOOTMETHF_GLOBAL;
+				is_global = ucp->flags & BOOTMETHF_GLOBAL;
 				if (is_global) {
 					iter->first_glob_method = i;
 					break;
@@ -193,6 +192,7 @@  int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global)
 	if (!count)
 		return log_msg_ret("count2", -ENOENT);
 
+	/* start with the global bootmeths */
 	if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && include_global &&
 	    iter->first_glob_method != -1 && iter->first_glob_method != count) {
 		iter->cur_method = iter->first_glob_method;
diff --git a/include/bootflow.h b/include/bootflow.h
index 284c23c59dd..4d1f888a5a8 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -263,7 +263,8 @@  enum bootflow_meth_flags_t {
  * @cur_label: Current label being processed
  * @num_methods: Number of bootmeth devices in @method_order
  * @cur_method: Current method number, an index into @method_order
- * @first_glob_method: First global method, if any, else -1
+ * @first_glob_method: Index of first global method within @method_order[], if
+ * any, else -1
  * @cur_prio: Current priority being scanned
  * @method_order: List of bootmeth devices to use, in order. The normal methods
  *	appear first, then the global ones, if any
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 14e3326a08f..be85032985d 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -439,7 +439,7 @@  static int bootflow_system(struct unit_test_state *uts)
 	ut_assertok(device_probe(dev));
 	sandbox_set_fake_efi_mgr_dev(dev, true);
 
-	/* We should get a single 'bootmgr' method right at the end */
+	/* We should get a single 'bootmgr' method at the start */
 	bootstd_clear_glob();
 	ut_assertok(run_command("bootflow scan -lH", 0));
 	ut_assert_skip_to_line(