All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Simon Glass <sjg@chromium.org>
Subject: [PATCH v3 02/12] bootstd: Refactor mmc prep to allow a different scan
Date: Sun,  1 Oct 2023 19:14:37 -0600	[thread overview]
Message-ID: <20231002011450.462468-2-sjg@chromium.org> (raw)
In-Reply-To: <20231002011450.462468-1-sjg@chromium.org>

Adjust scan_mmc4_bootdev() and related function so that the caller can
do its own 'bootflow scan' command. This allows it to change the flags
if needed.

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

Changes in v3:
- Add new patch to refactor mmc prep to allow a different scan

 test/boot/bootflow.c | 49 ++++++++++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 9 deletions(-)

diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index f5b2059140ac..0a992e2bcc14 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -511,19 +511,27 @@ BOOTSTD_TEST(bootflow_cmd_boot, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
 /**
  * prep_mmc_bootdev() - Set up an mmc bootdev so we can access other distros
  *
+ * After calling this function, set std->bootdev_order to *@old_orderp to
+ * restore normal operation of bootstd (i.e. with the original bootdev order)
+ *
  * @uts: Unit test state
- * @mmc_dev: MMC device to use, e.g. "mmc4"
+ * @mmc_dev: MMC device to use, e.g. "mmc4". Note that this must remain valid
+ *	in the caller until
+ * @bind_cros: true to bind the ChromiumOS bootmeth
+ * @old_orderp: Returns the original bootdev order, which must be restored
  * Returns 0 on success, -ve on failure
  */
 static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev,
-			    bool bind_cros)
+			    bool bind_cros, const char ***old_orderp)
 {
-	const char *order[] = {"mmc2", "mmc1", mmc_dev, NULL};
+	static const char *order[] = {"mmc2", "mmc1", NULL, NULL};
 	struct udevice *dev, *bootstd;
 	struct bootstd_priv *std;
 	const char **old_order;
 	ofnode root, node;
 
+	order[2] = mmc_dev;
+
 	/* Enable the mmc4 node since we need a second bootflow */
 	root = oftree_root(oftree_default());
 	node = ofnode_find_subnode(root, mmc_dev);
@@ -546,26 +554,49 @@ static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev,
 	std = dev_get_priv(bootstd);
 	old_order = std->bootdev_order;
 	std->bootdev_order = order;
+	*old_orderp = old_order;
+
+	return 0;
+}
+
+/**
+ * scan_mmc_bootdev() - Set up an mmc bootdev so we can access other distros
+ *
+ * @uts: Unit test state
+ * @mmc_dev: MMC device to use, e.g. "mmc4"
+ * @bind_cros: true to bind the ChromiumOS bootmeth
+ * Returns 0 on success, -ve on failure
+ */
+static int scan_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev,
+			    bool bind_cros)
+{
+	struct bootstd_priv *std;
+	struct udevice *bootstd;
+	const char **old_order;
+
+	ut_assertok(prep_mmc_bootdev(uts, mmc_dev, bind_cros, &old_order));
 
 	console_record_reset_enable();
 	ut_assertok(run_command("bootflow scan", 0));
 	ut_assert_console_end();
 
 	/* Restore the order used by the device tree */
+	ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd));
+	std = dev_get_priv(bootstd);
 	std->bootdev_order = old_order;
 
 	return 0;
 }
 
 /**
- * prep_mmc4_bootdev() - Set up the mmc4 bootdev so we can access a fake Armbian
+ * scan_mmc4_bootdev() - Set up the mmc4 bootdev so we can access a fake Armbian
  *
  * @uts: Unit test state
  * Returns 0 on success, -ve on failure
  */
-static int prep_mmc4_bootdev(struct unit_test_state *uts)
+static int scan_mmc4_bootdev(struct unit_test_state *uts)
 {
-	ut_assertok(prep_mmc_bootdev(uts, "mmc4", false));
+	ut_assertok(scan_mmc_bootdev(uts, "mmc4", false));
 
 	return 0;
 }
@@ -575,7 +606,7 @@ static int bootflow_cmd_menu(struct unit_test_state *uts)
 {
 	char prev[3];
 
-	ut_assertok(prep_mmc4_bootdev(uts));
+	ut_assertok(scan_mmc4_bootdev(uts));
 
 	/* Add keypresses to move to and select the second one in the list */
 	prev[0] = CTL_CH('n');
@@ -681,7 +712,7 @@ static int bootflow_menu_theme(struct unit_test_state *uts)
 	ofnode node;
 	int i;
 
-	ut_assertok(prep_mmc4_bootdev(uts));
+	ut_assertok(scan_mmc4_bootdev(uts));
 
 	ut_assertok(bootflow_menu_new(&exp));
 	node = ofnode_path("/bootstd/theme");
@@ -976,7 +1007,7 @@ BOOTSTD_TEST(bootflow_cmdline, 0);
 /* Test ChromiumOS bootmeth */
 static int bootflow_cros(struct unit_test_state *uts)
 {
-	ut_assertok(prep_mmc_bootdev(uts, "mmc5", true));
+	ut_assertok(scan_mmc_bootdev(uts, "mmc5", true));
 	ut_assertok(run_command("bootflow list", 0));
 
 	ut_assert_nextlinen("Showing all");
-- 
2.42.0.582.g8ccd20d70d-goog


  parent reply	other threads:[~2023-10-02  1:29 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-02  1:14 [PATCH v3 00/12] Resolve issues with booting distros on x86 Simon Glass
2023-10-02  1:14 ` [PATCH v3 01/12] efi: Correct handling of frame buffer Simon Glass
2023-11-05 14:06   ` Bin Meng
2023-11-15 13:17   ` Simon Glass
2023-10-02  1:14 ` Simon Glass [this message]
2023-10-02  1:14 ` [PATCH v3 03/12] bootstd: Add a return code to bootflow menu Simon Glass
2023-10-02  1:14 ` [PATCH v3 04/12] x86: coreboot: Add a boot script Simon Glass
2023-11-05 14:06   ` Bin Meng
2023-10-02  1:14 ` [PATCH v3 05/12] usb: Avoid unbinding devices in use by bootflows Simon Glass
2023-10-02  1:14 ` [PATCH v3 06/12] expo: Correct background colour Simon Glass
2023-11-05 14:06   ` Bin Meng
2023-11-15 13:17   ` Simon Glass
2023-10-02  1:14 ` [PATCH v3 07/12] video: Correct setting of cursor position Simon Glass
2023-11-12 20:01   ` Simon Glass
2023-11-12 20:27     ` Anatolij Gustschin
2023-11-12 20:25   ` Anatolij Gustschin
2023-10-02  1:14 ` [PATCH v3 08/12] video: Drop unnecessary truetype operations from SPL Simon Glass
2023-11-05 14:06   ` Bin Meng
2023-10-02  1:14 ` [PATCH v3 09/12] x86: Enable SSE in 64-bit mode Simon Glass
2023-11-05 14:05   ` Bin Meng
2023-11-05 16:29     ` Simon Glass
2023-11-06 10:26       ` Bin Meng
2023-11-06 15:36         ` Tom Rini
2023-11-12 20:01           ` Simon Glass
2023-11-13 13:01             ` Bin Meng
2023-11-13 14:00               ` Simon Glass
2023-11-13 14:06               ` Tom Rini
2023-11-13 14:11                 ` Simon Glass
2023-10-02  1:14 ` [PATCH v3 10/12] x86: coreboot: Enable truetype fonts Simon Glass
2023-10-02  1:14 ` [PATCH v3 11/12] x86: qemu: Expand ROM size Simon Glass
2023-10-02  1:14 ` [PATCH v3 12/12] x86: qemu: Enable truetype fonts Simon Glass
2023-11-15 13:17 ` [PATCH v3 03/12] bootstd: Add a return code to bootflow menu Simon Glass
2023-11-15 13:17 ` [PATCH v3 02/12] bootstd: Refactor mmc prep to allow a different scan Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231002011450.462468-2-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.