From: Marc Kleine-Budde <mkl@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 6/6] startup: introduce postenvironment_initcall
Date: Wed, 6 May 2015 14:51:31 +0200 [thread overview]
Message-ID: <1430916691-12459-6-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1430916691-12459-1-git-send-email-mkl@pengutronix.de>
From: Sascha Hauer <s.hauer@pengutronix.de>
To allow init code that depends on the environment being loaded.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
common/startup.c | 28 ++++++++++++++++++----------
include/asm-generic/barebox.lds.h | 4 +++-
include/init.h | 2 ++
3 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/common/startup.c b/common/startup.c
index e59b06d533e6..6178fc53531b 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");
diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h
index e359187d7f85..254397ee97b3 100644
--- a/include/asm-generic/barebox.lds.h
+++ b/include/asm-generic/barebox.lds.h
@@ -34,7 +34,9 @@
KEEP(*(.initcall.9)) \
KEEP(*(.initcall.10)) \
KEEP(*(.initcall.11)) \
- KEEP(*(.initcall.12))
+ KEEP(*(.initcall.12)) \
+ KEEP(*(.initcall.13)) \
+ KEEP(*(.initcall.14))
#define BAREBOX_CMDS KEEP(*(SORT_BY_NAME(.barebox_cmd*)))
diff --git a/include/init.h b/include/init.h
index 37c7eedf6747..f619c951d377 100644
--- a/include/init.h
+++ b/include/init.h
@@ -39,6 +39,8 @@ typedef int (*initcall_t)(void);
#define device_initcall(fn) __define_initcall("10",fn,10)
#define crypto_initcall(fn) __define_initcall("11",fn,11)
#define late_initcall(fn) __define_initcall("12",fn,12)
+#define environment_initcall(fn) __define_initcall("13",fn,13)
+#define postenvironment_initcall(fn) __define_initcall("14",fn,14)
/* section for code used very early when
* - we're not running from where we linked at
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-05-06 12:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-06 12:51 [PATCH 1/6] fdt: of_unflatten_dtb(): remove left over "root" argument from inline doc Marc Kleine-Budde
2015-05-06 12:51 ` [PATCH 2/6] state: documentation: add anchor so that state can be referenced later Marc Kleine-Budde
2015-05-06 12:51 ` [PATCH 3/6] state: state_uint32_create: use %u to print unsigned variable Marc Kleine-Budde
2015-05-06 12:51 ` [PATCH 4/6] state: state_new_from_fdt(): remove unused function Marc Kleine-Budde
2015-05-06 12:51 ` [PATCH 5/6] watchdog: add static inline no-ops if WD is disabled Marc Kleine-Budde
2015-05-06 12:51 ` Marc Kleine-Budde [this message]
2015-05-07 7:15 ` [PATCH 1/6] fdt: of_unflatten_dtb(): remove left over "root" argument from inline doc 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=1430916691-12459-6-git-send-email-mkl@pengutronix.de \
--to=mkl@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