[PATCH 2/4] boot: add helper to set default boot source from board file
Marco Felsch
m.felsch at pengutronix.de
Wed Mar 13 12:56:04 PDT 2024
Add a helper which can be called from board files to setup the
"boot.default" parameter to be independent of the initcall level.
Signed-off-by: Marco Felsch <m.felsch at pengutronix.de>
---
common/boot.c | 9 ++++++++-
include/boot.h | 1 +
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/common/boot.c b/common/boot.c
index dd9e26afc769..9cf9e9f391fd 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -115,11 +115,18 @@ struct watchdog *boot_get_enabled_watchdog(void)
}
static char *global_boot_default;
+
+void boot_set_default(const char *boot_default)
+{
+ free(global_boot_default);
+ global_boot_default = xstrdup(boot_default);
+}
+
static char *global_user;
static int init_boot(void)
{
- global_boot_default = xstrdup("net");
+ global_boot_default = global_boot_default ? : xstrdup("net");
globalvar_add_simple_string("boot.default", &global_boot_default);
globalvar_add_simple_int("boot.watchdog_timeout",
&boot_watchdog_timeout, "%u");
diff --git a/include/boot.h b/include/boot.h
index c9e8c0fd0d87..0f97901a9a72 100644
--- a/include/boot.h
+++ b/include/boot.h
@@ -44,6 +44,7 @@ int bootentry_register_provider(int (*fn)(struct bootentries *bootentries, const
struct watchdog;
+void boot_set_default(const char *boot_default);
void boot_set_watchdog_timeout(unsigned int timeout);
struct watchdog *boot_get_enabled_watchdog(void);
struct bootentries *bootentries_alloc(void);
--
2.39.2
More information about the barebox
mailing list