Introduce board_start_saveenv() and board_finish_saveenv(), two "weak"
functions that are called before and after saving the environment.  This
allows for board-specific functions that "prepare" the board for saving
the environment.  This is useful if, for some reason, the non-volatile
storage is normally unavailable (e.g. blocked via a mux).

Signed-off-by: Timur Tabi <ti...@freescale.com>
---
 common/cmd_nvedit.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index e1ccdd8..9637682 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -595,11 +595,33 @@ ulong getenv_ulong(const char *name, int base, ulong 
default_val)
 }
 
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
+
+static int __board_start_saveenv(void)
+{
+       return 0;
+}
+int board_start_saveenv(void) __attribute__((weak, 
alias("__board_start_saveenv")));
+
+static void __board_finish_saveenv(void)
+{
+}
+void board_finish_saveenv(void) __attribute__((weak, 
alias("__board_finish_saveenv")));
+
 int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
+       int ret;
+
        printf("Saving Environment to %s...\n", env_name_spec);
 
-       return saveenv() ? 1 : 0;
+       ret = board_start_saveenv();
+       if (ret)
+               return 0;
+
+       ret = saveenv() ? 1 : 0;
+
+       board_finish_saveenv();
+
+       return ret;
 }
 
 U_BOOT_CMD(
-- 
1.7.3.4


_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to