mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/4] boot: add helper to set default boot source from board file
Date: Wed, 13 Mar 2024 20:56:04 +0100	[thread overview]
Message-ID: <20240313195606.3911219-2-m.felsch@pengutronix.de> (raw)
In-Reply-To: <20240313195606.3911219-1-m.felsch@pengutronix.de>

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@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




  reply	other threads:[~2024-03-13 19:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13 19:56 [PATCH 1/4] fastboot: add support to set fastboot_bbu from board code Marco Felsch
2024-03-13 19:56 ` Marco Felsch [this message]
2024-03-13 19:56 ` [PATCH 3/4] startup: fix autoboot_state in case of abort Marco Felsch
2024-03-13 19:56 ` [PATCH 4/4] common: barebox_banner: fix missing newline Marco Felsch
2024-03-15  7:20 ` [PATCH 1/4] fastboot: add support to set fastboot_bbu from board code Sascha Hauer

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=20240313195606.3911219-2-m.felsch@pengutronix.de \
    --to=m.felsch@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