From 041b2bd31fe1e6b77fb445da3bd3c2fcb5612ae3 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 6 May 2015 14:51:31 +0200 Subject: startup: introduce postenvironment_initcall To allow init code that depends on the environment being loaded. Signed-off-by: Sascha Hauer Signed-off-by: Marc Kleine-Budde Signed-off-by: Sascha Hauer --- common/startup.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'common/startup.c') diff --git a/common/startup.c b/common/startup.c index e59b06d533..6178fc5353 100644 --- a/common/startup.c +++ b/common/startup.c @@ -62,6 +62,24 @@ static int mount_root(void) fs_initcall(mount_root); #endif +#ifdef CONFIG_ENV_HANDLING +static int load_environment(void) +{ + const char *default_environment_path; + + default_environment_path = default_environment_path_get(); + + if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT)) + defaultenv_load("/env", 0); + + envfs_load(default_environment_path, "/env", 0); + nvvar_load(); + + return 0; +} +environment_initcall(load_environment); +#endif + int (*barebox_main)(void); void __noreturn start_barebox(void) @@ -84,16 +102,6 @@ void __noreturn start_barebox(void) pr_debug("initcalls done\n"); - if (IS_ENABLED(CONFIG_ENV_HANDLING)) { - char *default_environment_path = default_environment_path_get(); - - if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT)) - defaultenv_load("/env", 0); - - envfs_load(default_environment_path, "/env", 0); - nvvar_load(); - } - if (IS_ENABLED(CONFIG_COMMAND_SUPPORT)) { pr_info("running /env/bin/init...\n"); -- cgit v1.2.3