[PATCH] bootm: wrap image_data::dryrun in new bootm_abort helper
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Sep 29 23:16:21 PDT 2022
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 at 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
More information about the barebox
mailing list