[RFC,2/4] env; fat: Allow the fat environment to be embedded by another one

Message ID 20171025122601.28224-3-maxime.ripard@free-electrons.com
State New
Headers show
Series
  • sunxi: Implement transition in environment
Related show

Commit Message

Maxime Ripard Oct. 25, 2017, 12:25 p.m.
The fat environment is currently only buildable as the primary environment,
but other environment methods might need to use it as a secondary
environment (for example to implement fallback mechanisms).

Make sure the environment can be compiled and that the functions are not
static when the configuration option is not enabled, and that we will
register it only when it is our primary environment method.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 env/fat.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Patch

diff --git a/env/fat.c b/env/fat.c
index ec49c3905369..acdea664dd2c 100644
--- a/env/fat.c
+++ b/env/fat.c
@@ -34,7 +34,10 @@ 
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CMD_SAVEENV
-static int env_fat_save(void)
+#ifdef CONFIG_ENV_IS_IN_FAT
+static
+#endif
+int env_fat_save(void)
 {
 	env_t	env_new;
 	struct blk_desc *dev_desc = NULL;
@@ -74,7 +77,10 @@  static int env_fat_save(void)
 #endif /* CMD_SAVEENV */
 
 #ifdef LOADENV
-static int env_fat_load(void)
+#ifdef CONFIG_ENV_IS_IN_FAT
+static
+#endif
+int env_fat_load(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
 	struct blk_desc *dev_desc = NULL;
@@ -112,6 +118,7 @@  err_env_relocate:
 }
 #endif /* LOADENV */
 
+#ifdef CONFIG_ENV_IS_IN_FAT
 U_BOOT_ENV_LOCATION(fat) = {
 	.location	= ENVL_FAT,
 	ENV_NAME("FAT")
@@ -122,3 +129,4 @@  U_BOOT_ENV_LOCATION(fat) = {
 	.save		= env_save_ptr(env_fat_save),
 #endif
 };
+#endif