[PATCH 29/71] bootstd: Add an MMC hunter

Simon Glass sjg at chromium.org
Wed Dec 7 09:50:55 CET 2022


Add a hunter for MMC. This doesn't do anything at present, since MMC is
currently set up when U-Boot starts. If MMC moves to lazy init then we can
add a hunter function.

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

 drivers/mmc/mmc_bootdev.c |  6 ++++++
 test/boot/bootdev.c       | 16 ++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/mmc_bootdev.c b/drivers/mmc/mmc_bootdev.c
index 037b67bc0ff..300208f0c71 100644
--- a/drivers/mmc/mmc_bootdev.c
+++ b/drivers/mmc/mmc_bootdev.c
@@ -35,3 +35,9 @@ U_BOOT_DRIVER(mmc_bootdev) = {
 	.bind		= mmc_bootdev_bind,
 	.of_match	= mmc_bootdev_ids,
 };
+
+BOOTDEV_HUNTER(mmc_bootdev_hunter) = {
+	.prio		= BOOTDEVP_0_INTERNAL_FAST,
+	.uclass		= UCLASS_MMC,
+	.drv		= DM_DRIVER_REF(mmc_bootdev),
+};
diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c
index 7a0c5793890..78cb0ac628a 100644
--- a/test/boot/bootdev.c
+++ b/test/boot/bootdev.c
@@ -238,8 +238,9 @@ static int bootdev_test_hunter(struct unit_test_state *uts)
 	bootdev_list_hunters(std);
 	ut_assert_nextline("Prio  Used  Uclass           Hunter");
 	ut_assert_nextlinen("----");
+	ut_assert_nextline("  10        mmc              mmc_bootdev");
 	ut_assert_nextline("  40        usb              usb_bootdev");
-	ut_assert_nextline("(total hunters: 1)");
+	ut_assert_nextline("(total hunters: 2)");
 	ut_assert_console_end();
 
 	ut_assertok(bootdev_hunt("usb1", false));
@@ -247,7 +248,8 @@ static int bootdev_test_hunter(struct unit_test_state *uts)
 		"Bus usb at 1: scanning bus usb at 1 for devices... 5 USB Device(s) found");
 	ut_assert_console_end();
 
-	ut_asserteq(GENMASK(0, 0), std->hunters_used);
+	/* USB is second in the list, so bit 1 */
+	ut_asserteq(BIT(1), std->hunters_used);
 
 	return 0;
 }
@@ -267,12 +269,12 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts)
 	ut_assertok(run_command("bootdev hunt -l", 0));
 	ut_assert_nextline("Prio  Used  Uclass           Hunter");
 	ut_assert_nextlinen("----");
-	ut_assert_nextline("  40        usb              usb_bootdev");
-	ut_assert_nextline("(total hunters: 1)");
+	ut_assert_skip_to_line("(total hunters: 2)");
 	ut_assert_console_end();
 
 	/* Scan all hunters */
 	ut_assertok(run_command("bootdev hunt", 0));
+	ut_assert_nextline("Hunting with: mmc");
 	ut_assert_nextline("Hunting with: usb");
 	ut_assert_nextline(
 		"Bus usb at 1: scanning bus usb at 1 for devices... 5 USB Device(s) found");
@@ -282,11 +284,13 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts)
 	ut_assertok(run_command("bootdev hunt -l", 0));
 	ut_assert_nextlinen("Prio");
 	ut_assert_nextlinen("----");
+	ut_assert_nextline("  10     *  mmc              mmc_bootdev");
 	ut_assert_nextline("  40     *  usb              usb_bootdev");
-	ut_assert_nextline("(total hunters: 1)");
+
+	ut_assert_nextline("(total hunters: 2)");
 	ut_assert_console_end();
 
-	ut_asserteq(GENMASK(0, 0), std->hunters_used);
+	ut_asserteq(GENMASK(1, 0), std->hunters_used);
 
 	return 0;
 }
-- 
2.39.0.rc0.267.gcb52ba06e7-goog



More information about the U-Boot-Custodians mailing list