mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] bootm: wrap image_data::dryrun in new bootm_abort helper
Date: Fri, 30 Sep 2022 08:16:21 +0200	[thread overview]
Message-ID: <20220930061621.60683-1-a.fatoum@pengutronix.de> (raw)

bootm handlers are expected to check the dryrun member just before
shutting down barebox and handing off execution. In future, we may want
to do the same dependent on board code decision, e.g. OTG port is placed
into host mode, then boot proceeds normally, then at the very end,
attached USB drives are checked for an alternate boot method that would
abort the current boot mode. Doing it this way eliminates waiting times
for normal boot compared to the alternative of waiting for a while until
USB drives may be enumerated correctly.

As first step towards enabling this in the future, replace direct
evaluation of image_data::dryrun with the new bootm_abort() helper.

At present, this introduces no functional change, but we may extend
bootm_abort() in future to call board code a supplied abort check
function.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/lib32/bootm.c            | 2 +-
 arch/arm/lib64/armlinux.c         | 2 +-
 arch/arm/mach-omap/omap_generic.c | 2 +-
 arch/kvx/lib/bootm.c              | 2 +-
 arch/mips/lib/bootm.c             | 2 +-
 arch/powerpc/lib/ppclinux.c       | 2 +-
 arch/riscv/lib/bootm.c            | 2 +-
 common/efi/payload/image.c        | 2 +-
 include/bootm.h                   | 5 +++++
 9 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
index e814593dce43..562837be10bc 100644
--- a/arch/arm/lib32/bootm.c
+++ b/arch/arm/lib32/bootm.c
@@ -324,7 +324,7 @@ static int __do_bootm_linux(struct image_data *data, unsigned long free_mem,
 		       bootm_arm_security_state_name(state));
 	}
 
-	if (data->dryrun)
+	if (bootm_abort(data))
 		return 0;
 
 	ret = of_overlay_load_firmware();
diff --git a/arch/arm/lib64/armlinux.c b/arch/arm/lib64/armlinux.c
index 8382ffdf1b04..cca26adee30a 100644
--- a/arch/arm/lib64/armlinux.c
+++ b/arch/arm/lib64/armlinux.c
@@ -17,7 +17,7 @@ static int do_bootm_linux(struct image_data *data)
 	if (IS_ERR(fn))
 		return PTR_ERR(fn);
 
-	if (data->dryrun)
+	if (bootm_abort(data))
 		return 0;
 
 	ret = of_overlay_load_firmware();
diff --git a/arch/arm/mach-omap/omap_generic.c b/arch/arm/mach-omap/omap_generic.c
index 6bb26a6ef0fa..7992d6c8aaec 100644
--- a/arch/arm/mach-omap/omap_generic.c
+++ b/arch/arm/mach-omap/omap_generic.c
@@ -97,7 +97,7 @@ static int do_bootm_omap_barebox(struct image_data *data)
 	if (!barebox)
 		return -EINVAL;
 
-	if (data->dryrun) {
+	if (bootm_abort(data)) {
 		free(barebox);
 		return 0;
 	}
diff --git a/arch/kvx/lib/bootm.c b/arch/kvx/lib/bootm.c
index 4c77f676ec0b..69e09ab11fc0 100644
--- a/arch/kvx/lib/bootm.c
+++ b/arch/kvx/lib/bootm.c
@@ -27,7 +27,7 @@ static int do_boot_entry(struct image_data *data, boot_func_entry entry,
 
 	printf("starting elf (entry at %p)\n", entry);
 
-	if (data->dryrun)
+	if (bootm_abort(data))
 		return 0;
 
 	ret = of_overlay_load_firmware();
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 655535737ec8..9aa53d0fa966 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -22,7 +22,7 @@ static int do_bootm_barebox(struct image_data *data)
 	if (!barebox)
 		return -EINVAL;
 
-	if (data->dryrun) {
+	if (bootm_abort(data)) {
 		free(barebox);
 		return 0;
 	}
diff --git a/arch/powerpc/lib/ppclinux.c b/arch/powerpc/lib/ppclinux.c
index 9b8404962cea..a50408b6803b 100644
--- a/arch/powerpc/lib/ppclinux.c
+++ b/arch/powerpc/lib/ppclinux.c
@@ -66,7 +66,7 @@ static int do_bootm_linux(struct image_data *data)
 		return -EINVAL;
 	}
 
-	if (data->dryrun)
+	if (bootm_abort(data))
 		return 0;
 
 	ret = of_overlay_load_firmware();
diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c
index 6984f282be4d..2678bcd985d5 100644
--- a/arch/riscv/lib/bootm.c
+++ b/arch/riscv/lib/bootm.c
@@ -16,7 +16,7 @@ static int do_bootm_linux(struct image_data *data)
 	if (IS_ERR(fn))
 		return PTR_ERR(fn);
 
-	if (data->dryrun)
+	if (bootm_abort(data))
 		return 0;
 
 	ret = of_overlay_load_firmware();
diff --git a/common/efi/payload/image.c b/common/efi/payload/image.c
index e63da9ddf06f..36c70131d6b8 100644
--- a/common/efi/payload/image.c
+++ b/common/efi/payload/image.c
@@ -241,7 +241,7 @@ static int do_bootm_efi(struct image_data *data)
 		printf("...\n");
 	}
 
-	if (data->dryrun) {
+	if (bootm_abort(data)) {
 		BS->unload_image(handle);
 		free(boot_header);
 		free(initrd);
diff --git a/include/bootm.h b/include/bootm.h
index 655c5152d97e..4d7eab28c2a9 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -132,6 +132,11 @@ static inline int bootm_verbose(struct image_data *data)
 }
 #endif
 
+static inline int bootm_abort(struct image_data *data)
+{
+	return data->dryrun;
+}
+
 void bootm_data_init_defaults(struct bootm_data *data);
 
 int bootm_load_os(struct image_data *data, unsigned long load_address);
-- 
2.30.2




                 reply	other threads:[~2022-09-30  6:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220930061621.60683-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox