[PATCH 67/71] bootstd: Drop the old bootflow_scan_first()

Simon Glass sjg at chromium.org
Wed Dec 7 09:51:33 CET 2022


This function is not used outside tests. Drop it and rename
bootflow_scan_dev() since it is how we start a scan now.

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

 boot/bootflow.c      | 18 +++---------------
 cmd/bootflow.c       |  2 +-
 include/bootflow.h   | 23 +++--------------------
 test/boot/bootdev.c  | 16 +++++++++-------
 test/boot/bootflow.c |  5 +++--
 5 files changed, 19 insertions(+), 45 deletions(-)

diff --git a/boot/bootflow.c b/boot/bootflow.c
index da462a6ffdc..61a4f16599c 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -324,9 +324,9 @@ static int bootflow_check(struct bootflow_iter *iter, struct bootflow *bflow)
 	return 0;
 }
 
-int bootflow_scan_bootdev(struct udevice *dev, const char *label,
-			  struct bootflow_iter *iter, int flags,
-			  struct bootflow *bflow)
+int bootflow_scan_first(struct udevice *dev, const char *label,
+			struct bootflow_iter *iter, int flags,
+			struct bootflow *bflow)
 {
 	int ret;
 
@@ -371,18 +371,6 @@ int bootflow_scan_bootdev(struct udevice *dev, const char *label,
 	return 0;
 }
 
-int bootflow_scan_first(struct bootflow_iter *iter, int flags,
-			struct bootflow *bflow)
-{
-	int ret;
-
-	ret = bootflow_scan_bootdev(NULL, NULL, iter, flags, bflow);
-	if (ret)
-		return log_msg_ret("start", ret);
-
-	return 0;
-}
-
 int bootflow_scan_next(struct bootflow_iter *iter, struct bootflow *bflow)
 {
 	int ret;
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 040ecf3a088..2a3e47ebccb 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -161,7 +161,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc,
 	else
 		bootstd_clear_glob();
 	for (i = 0,
-	     ret = bootflow_scan_bootdev(dev, label, &iter, flags, &bflow);
+	     ret = bootflow_scan_first(dev, label, &iter, flags, &bflow);
 	     i < 1000 && ret != -ENODEV;
 	     i++, ret = bootflow_scan_next(&iter, &bflow)) {
 		bflow.err = ret;
diff --git a/include/bootflow.h b/include/bootflow.h
index 738edd22a0a..5b0bdc7e684 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -238,7 +238,7 @@ int bootflow_iter_drop_bootmeth(struct bootflow_iter *iter,
 				const struct udevice *bmeth);
 
 /**
- * bootflow_scan_bootdev() - find the first bootflow in a bootdev
+ * bootflow_scan_first() - find the first bootflow for a device or label
  *
  * If @flags includes BOOTFLOWF_ALL then bootflows with errors are returned too
  *
@@ -253,25 +253,8 @@ int bootflow_iter_drop_bootmeth(struct bootflow_iter *iter,
  * Return: 0 if found,  -ENODEV if no device, other -ve on other error
  *	(iteration can continue)
  */
-int bootflow_scan_bootdev(struct udevice *dev, const char *label,
-			  struct bootflow_iter *iter, int flags,
-			  struct bootflow *bflow);
-
-/**
- * bootflow_scan_first() - find the first bootflow
- *
- * This works through the available bootdev devices until it finds one that
- * can supply a bootflow. It then returns that
- *
- * If @flags includes BOOTFLOWF_ALL then bootflows with errors are returned too
- *
- * @iter:	Place to store private info (inited by this call), with
- * @flags:	Flags for bootdev (enum bootflow_flags_t)
- * @bflow:	Place to put the bootflow if found
- * Return: 0 if found, -ENODEV if no device, other -ve on other error (iteration
- *	can continue)
- */
-int bootflow_scan_first(struct bootflow_iter *iter, int flags,
+int bootflow_scan_first(struct udevice *dev, const char *label,
+			struct bootflow_iter *iter, int flags,
 			struct bootflow *bflow);
 
 /**
diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c
index 1724e34af3e..5d5ce7f48cf 100644
--- a/test/boot/bootdev.c
+++ b/test/boot/bootdev.c
@@ -203,7 +203,7 @@ static int bootdev_test_order(struct unit_test_state *uts)
 	 * mmc2 - nothing connected
 	 */
 	ut_assertok(env_set("boot_targets", NULL));
-	ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
+	ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow));
 	ut_asserteq(2, iter.num_devs);
 	ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name);
 	ut_asserteq_str("mmc1.bootdev", iter.dev_order[1]->name);
@@ -211,7 +211,7 @@ static int bootdev_test_order(struct unit_test_state *uts)
 
 	/* Use the environment variable to override it */
 	ut_assertok(env_set("boot_targets", "mmc1 mmc2"));
-	ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
+	ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow));
 	ut_asserteq(2, iter.num_devs);
 	ut_asserteq_str("mmc1.bootdev", iter.dev_order[0]->name);
 	ut_asserteq_str("mmc2.bootdev", iter.dev_order[1]->name);
@@ -224,7 +224,7 @@ static int bootdev_test_order(struct unit_test_state *uts)
 	ut_assertok(env_set("boot_targets", NULL));
 	ut_assertok(bootstd_test_drop_bootdev_order(uts));
 
-	ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
+	ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow));
 	ut_asserteq(3, iter.num_devs);
 	ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name);
 	ut_asserteq_str("mmc1.bootdev", iter.dev_order[1]->name);
@@ -239,7 +239,7 @@ static int bootdev_test_order(struct unit_test_state *uts)
 	iter.dev_order[2]->seq_ = 2;
 	bootflow_iter_uninit(&iter);
 
-	ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
+	ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow));
 	ut_asserteq(3, iter.num_devs);
 	ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name);
 	ut_asserteq_str("mmc0.bootdev", iter.dev_order[1]->name);
@@ -268,7 +268,7 @@ static int bootdev_test_prio(struct unit_test_state *uts)
 
 	/* 3 MMC and 3 USB bootdevs: MMC should come before USB */
 	console_record_reset_enable();
-	ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
+	ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow));
 	ut_asserteq(6, iter.num_devs);
 	ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name);
 	ut_asserteq_str("usb_mass_storage.lun0.bootdev",
@@ -282,7 +282,8 @@ static int bootdev_test_prio(struct unit_test_state *uts)
 	ucp->prio = 1;
 
 	bootflow_iter_uninit(&iter);
-	ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
+	ut_assertok(bootflow_scan_first(NULL, NULL, &iter, BOOTFLOWF_HUNT,
+					&bflow));
 	ut_asserteq(6, iter.num_devs);
 	ut_asserteq_str("usb_mass_storage.lun0.bootdev",
 			iter.dev_order[0]->name);
@@ -415,7 +416,8 @@ static int bootdev_test_hunt_scan(struct unit_test_state *uts)
 	ut_assertok(bootstd_get_priv(&std));
 
 	ut_assertok(bootstd_test_drop_bootdev_order(uts));
-	ut_assertok(bootflow_scan_first(&iter, BOOTFLOWF_SHOW | BOOTFLOWF_HUNT |
+	ut_assertok(bootflow_scan_first(NULL, NULL, &iter,
+					BOOTFLOWF_SHOW | BOOTFLOWF_HUNT |
 					BOOTFLOWF_SKIP_GLOBAL, &bflow));
 	ut_asserteq(BIT(MMC_HUNTER) | BIT(1), std->hunters_used);
 
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 6c7e7c813f3..25186e3f820 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -266,7 +266,8 @@ static int bootflow_iter(struct unit_test_state *uts)
 
 	/* The first device is mmc2.bootdev which has no media */
 	ut_asserteq(-EPROTONOSUPPORT,
-		    bootflow_scan_first(&iter, BOOTFLOWF_ALL | BOOTFLOWF_SKIP_GLOBAL, &bflow));
+		    bootflow_scan_first(NULL, NULL, &iter,
+					BOOTFLOWF_ALL | BOOTFLOWF_SKIP_GLOBAL, &bflow));
 	ut_asserteq(2, iter.num_methods);
 	ut_asserteq(0, iter.cur_method);
 	ut_asserteq(0, iter.part);
@@ -405,7 +406,7 @@ static int bootflow_iter_disable(struct unit_test_state *uts)
 
 	/* Try to boot the bootmgr flow, which will fail */
 	console_record_reset_enable();
-	ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
+	ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow));
 	ut_asserteq(3, iter.num_methods);
 	ut_asserteq_str("sandbox", iter.method->name);
 	ut_assertok(inject_response(uts));
-- 
2.39.0.rc0.267.gcb52ba06e7-goog



More information about the U-Boot mailing list