[U-Boot] [PATCH 5/6] cmd_nvedit.c: allow board-specific code before/after saving the environment
Timur Tabi
timur at freescale.com
Sat May 5 00:21:31 CEST 2012
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 <timur at 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
More information about the U-Boot
mailing list