mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Juergen Beisert <jbe@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/5] Move environment handling out from the main routine
Date: Wed,  9 Mar 2011 16:17:22 +0100	[thread overview]
Message-ID: <1299683846-20616-2-git-send-email-jbe@pengutronix.de> (raw)
In-Reply-To: <1299683846-20616-1-git-send-email-jbe@pengutronix.de>

This is for easier integration of multi environment handling.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 common/startup.c |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/common/startup.c b/common/startup.c
index aa76cb7..c39b08e 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -112,6 +112,26 @@ static int mount_root(void)
 }
 fs_initcall(mount_root);
 
+static void __maybe_unused load_default_environment(void)
+{
+#ifdef CONFIG_DEFAULT_ENVIRONMENT
+	printf("No valid environment found. Using default environment.\n");
+	envfs_load("/dev/defaultenv", "/env");
+#endif
+}
+
+static int __maybe_unused init_single_envfs_load(void)
+{
+	if (envfs_load("/dev/env0", "/env"))
+		load_default_environment();
+
+	return 0;
+}
+
+#ifdef CONFIG_ENV_HANDLING
+late_initcall(init_single_envfs_load);
+#endif
+
 void start_barebox (void)
 {
 	initcall_t *initcall;
@@ -139,15 +159,6 @@ void start_barebox (void)
 
 	display_meminfo();
 
-#ifdef CONFIG_ENV_HANDLING
-	if (envfs_load("/dev/env0", "/env")) {
-#ifdef CONFIG_DEFAULT_ENVIRONMENT
-		printf("no valid environment found on /dev/env0. "
-			"Using default environment\n");
-		envfs_load("/dev/defaultenv", "/env");
-#endif
-	}
-#endif
 	printf("running /env/bin/init...\n");
 
 	if (!stat("/env/bin/init", &s)) {
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2011-03-09 15:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-09 15:17 [RFC] Support multiple environments in barebox Juergen Beisert
2011-03-09 15:17 ` Juergen Beisert [this message]
2011-03-09 15:17 ` [PATCH 2/5] CRC value handling and dry run mode in 'envfs_load' Juergen Beisert
2011-03-09 15:17 ` [PATCH 3/5] Add generic routine for environment partition handling Juergen Beisert
2011-03-09 15:17 ` [PATCH 4/5] Add multi environment support Juergen Beisert
2011-03-09 15:17 ` [PATCH 5/5] " Juergen Beisert
2011-08-14  6:09   ` Boaz Ben-David
2011-08-14  6:12   ` Boaz Ben-David

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=1299683846-20616-2-git-send-email-jbe@pengutronix.de \
    --to=jbe@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