summaryrefslogtreecommitdiff
path: root/common/env_common.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2008-07-07 15:40:39 +0800
committerWolfgang Denk <wd@denx.de>2008-07-10 00:28:20 +0200
commit5bb12dbd7ae03189b6c13d8737b5a1b37c3df698 (patch)
tree4e761b4b8bcf58c14e331640242cb9ed12ceb91d /common/env_common.c
parentc3bf1ad7baa1b0dd989dedc260b7098b6089ae05 (diff)
downloadu-boot-imx-5bb12dbd7ae03189b6c13d8737b5a1b37c3df698.zip
u-boot-imx-5bb12dbd7ae03189b6c13d8737b5a1b37c3df698.tar.gz
u-boot-imx-5bb12dbd7ae03189b6c13d8737b5a1b37c3df698.tar.bz2
Remove code duplication for setting the default environment
common/env_common.c (default_env): new function that resets the environment to the default value common/env_common.c (env_relocate): use default_env instead of own copy common/env_nand.c (env_relocate_spec): use default_env instead of own copy include/environment.h: added default_env prototype Signed-off-by: Werner Almesberger <werner@openmoko.org> Signed-off-by: Harald Welte <laforge@openmoko.org>
Diffstat (limited to 'common/env_common.c')
-rw-r--r--common/env_common.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/common/env_common.c b/common/env_common.c
index 5ac14e8..d51c211 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -204,6 +204,23 @@ uchar *env_get_addr (int index)
}
}
+void set_default_env(void)
+{
+ if (sizeof(default_environment) > ENV_SIZE) {
+ puts ("*** Error - default environment is too large\n\n");
+ return;
+ }
+
+ memset(env_ptr, 0, sizeof(env_t));
+ memcpy(env_ptr->data, default_environment,
+ sizeof(default_environment));
+#ifdef CFG_REDUNDAND_ENVIRONMENT
+ env_ptr->flags = 0xFF;
+#endif
+ env_crc_update ();
+ gd->env_valid = 1;
+}
+
void env_relocate (void)
{
DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__,
@@ -235,22 +252,7 @@ void env_relocate (void)
puts ("*** Warning - bad CRC, using default environment\n\n");
show_boot_progress (-60);
#endif
-
- if (sizeof(default_environment) > ENV_SIZE)
- {
- puts ("*** Error - default environment is too large\n\n");
- return;
- }
-
- memset (env_ptr, 0, sizeof(env_t));
- memcpy (env_ptr->data,
- default_environment,
- sizeof(default_environment));
-#ifdef CFG_REDUNDAND_ENVIRONMENT
- env_ptr->flags = 0xFF;
-#endif
- env_crc_update ();
- gd->env_valid = 1;
+ set_default_env();
}
else {
env_relocate_spec ();