diff options
Diffstat (limited to 'common/env_common.c')
-rw-r--r-- | common/env_common.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/common/env_common.c b/common/env_common.c index c3e6388ac0..04a947e92b 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -196,6 +196,14 @@ void set_default_env(const char *s) gd->flags |= GD_FLG_ENV_READY; } +int env_check_valid(const char *buf) +{ + env_t *ep = (env_t *)buf; + uint32_t crc; + + memcpy(&crc, &ep->crc, sizeof(crc)); + return crc32(0, ep->data, ENV_SIZE) == crc; +} /* * Check if CRC is valid and (if yes) import the environment. * Note that "buf" may or may not be aligned. @@ -205,11 +213,7 @@ int env_import(const char *buf, int check) env_t *ep = (env_t *)buf; if (check) { - uint32_t crc; - - memcpy(&crc, &ep->crc, sizeof(crc)); - - if (crc32(0, ep->data, ENV_SIZE) != crc) { + if (!env_check_valid(buf)) { set_default_env("!bad CRC"); return 0; } @@ -244,6 +248,9 @@ void env_relocate (void) } else { env_relocate_spec (); } +#ifdef CONFIG_TOUCHUP_ENV + touchup_env(); +#endif } #ifdef CONFIG_AUTO_COMPLETE |