[PATCH 08/25] fastboot: Avoid depending on CMDLINE

Simon Glass sjg at chromium.org
Sun Sep 24 22:39:26 CEST 2023


When CMDLINE is not enabled, this code fails to build. Correct this by
adding conditions.

Note that this should not happen in normal use, since the use of
'select CMDLINE' will cause a visible warning. But it is needed for the
sandbox build to pass without CMDLINE.

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

 drivers/fastboot/fb_command.c |  3 ++-
 drivers/fastboot/fb_common.c  | 15 +++++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
index 71cfaec6e9dc..4e52e6f0f8bf 100644
--- a/drivers/fastboot/fb_command.c
+++ b/drivers/fastboot/fb_command.c
@@ -346,7 +346,8 @@ static char g_a_cmd_buff[64];
 
 void fastboot_acmd_complete(void)
 {
-	run_command(g_a_cmd_buff, 0);
+	if (IS_ENABLED(CONFIG_CMDLINE))
+		run_command(g_a_cmd_buff, 0);
 }
 
 /**
diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index 4e9d9b719c6f..35b7aafe5af3 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -132,6 +132,13 @@ void fastboot_boot(void)
 {
 	char *s;
 
+	/*
+	 * Avoid a build error; this will always have generated a Kconfig
+	 * warning about CMDLINE not being enabled
+	 */
+	if (!IS_ENABLED(CONFIG_CMDLINE))
+		return;
+
 	s = env_get("fastboot_bootcmd");
 	if (s) {
 		run_command(s, CMD_FLAG_ENV);
@@ -170,8 +177,12 @@ void fastboot_handle_boot(int command, bool success)
 
 	switch (command) {
 	case FASTBOOT_COMMAND_BOOT:
-		fastboot_boot();
-		net_set_state(NETLOOP_SUCCESS);
+		if (IS_ENABLED(CONFIG_CMDLINE)) {
+			fastboot_boot();
+			net_set_state(NETLOOP_SUCCESS);
+		} else {
+			net_set_state(NETLOOP_FAIL);
+		}
 		break;
 
 	case FASTBOOT_COMMAND_CONTINUE:
-- 
2.42.0.515.g380fc7ccd1-goog



More information about the U-Boot mailing list