[PATCH 1/5] Move environment handling out from the main routine

Juergen Beisert jbe at pengutronix.de
Wed Mar 9 10:17:22 EST 2011


This is for easier integration of multi environment handling.

Signed-off-by: Juergen Beisert <jbe at 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




More information about the barebox mailing list