env: Fix up invalid environment in env_init()
PATCH 1/3 env: Fix up invalid environment in env_init()
This should be set to valid, not invalid. Otherwise the environment will not load after relocation.
---
env/env.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
env/env.c +1 -1
@@ -138,7 +138,7 @@ int env_init(void) ret = drv->init ();if (ret == -ENOENT ) { gd->env_addr = (ulong)&default_environment[0 ]; - gd->env_valid =0 ; + gd->env_valid =ENV_VALID ;return 0 ; }else if (ret) {
Signature · 1 line
2.14.1.480.gb18f417b89-goog
PATCH 2/3 env: Allow env_load() to detect errors
Now that we have errors available in the environment driver's load() method, check the return valid.
---
env/env.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
env/env.c +1 -1
@@ -98,7 +98,7 @@ int env_load(void)return -ENODEV ;if (!drv->load)return 0 ; - drv->load ();/* TODO(sjg at chromium.org): Make this return an error */ + ret = drv->load ();if (ret) {debug ("%s: Environment failed to load (err=%d)\n" , __func__, ret);
Signature · 1 line
2.14.1.480.gb18f417b89-goog
PATCH 3/3 env: Replace all open-coded gd->env_valid values with ENV_ flags
In reply to Simon GlassSome of these were missed in the conversion.
---
env/common.c | 20 ++++++++++---------- env/eeprom.c | 6 +++--- env/env.c | 2 +- env/flash.c | 4 ++-- env/nand.c | 2 +- env/nvram.c | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-)
env/common.c +10 -10
@@ -52,7 +52,7 @@ char *env_get_default(const char *name)/* Pretend that the image is bad. */ gd->flags &= ~GD_FLG_ENV_READY ; - gd->env_valid =0 ; + gd->env_valid =ENV_INVALID ; ret_val =env_get (name); gd->env_valid = really_valid; gd->flags = real_gd_flags;
@@ -210,24 +210,24 @@ int env_import_redund(const char *buf1, const char *buf2)set_default_env ("!bad CRC" );return 0 ; }else if (crc1_ok && !crc2_ok) { - gd->env_valid =1 ; + gd->env_valid =ENV_VALID ; }else if (!crc1_ok && crc2_ok) { - gd->env_valid =2 ; + gd->env_valid =ENV_REDUND ; }else {/* both ok - check serial */ if (tmp_env1->flags ==255 && tmp_env2->flags ==0 ) - gd->env_valid =2 ; + gd->env_valid =ENV_REDUND ;else if (tmp_env2->flags ==255 && tmp_env1->flags ==0 ) - gd->env_valid =1 ; + gd->env_valid =ENV_VALID ;else if (tmp_env1->flags > tmp_env2->flags) - gd->env_valid =1 ; + gd->env_valid =ENV_VALID ;else if (tmp_env2->flags > tmp_env1->flags) - gd->env_valid =2 ; + gd->env_valid =ENV_REDUND ;else /* flags are equal - almost impossible */ - gd->env_valid =1 ; + gd->env_valid =ENV_VALID ; } -if (gd->env_valid ==1 ) +if (gd->env_valid ==ENV_VALID ) ep = tmp_env1;else ep = tmp_env2;
@@ -271,7 +271,7 @@ void env_relocate(void)env_reloc (); env_htab.change_ok += gd->reloc_off;#endif -if (gd->env_valid ==0 ) { +if (gd->env_valid ==ENV_INVALID ) {#if defined(CONFIG_ENV_IS_NOWHERE ) || defined(CONFIG_SPL_BUILD )/* Environment not changable */ set_default_env (NULL );
env/eeprom.c +3 -3
@@ -122,7 +122,7 @@ static int env_eeprom_load(void)if (!crc_ok[0 ] && !crc_ok[1 ]) { gd->env_addr =0 ; - gd->env_valid =0 ; + gd->env_valid =ENV_INVALID ; }else if (crc_ok[0 ] && !crc_ok[1 ]) { gd->env_valid =ENV_VALID ; }else if (!crc_ok[0 ] && crc_ok[1 ]) {
@@ -166,9 +166,9 @@ static int env_eeprom_load(void) }if (crc == new) { - gd->env_valid =ENV_VALID ; + gd->env_valid =ENV_VALID ; }else { - gd->env_valid =0 ; + gd->env_valid =ENV_INVALID ; }#endif /* CONFIG_ENV_OFFSET_REDUND */
env/env.c +1 -1
@@ -74,7 +74,7 @@ int env_get_char(int index)struct env_driver *drv =env_driver_lookup_default ();int ret; -if (!gd->env_valid) +if (gd->env_valid ==ENV_INVALID )return default_environment[index];if (!drv)return -ENODEV ;
env/flash.c +2 -2
@@ -94,7 +94,7 @@ static int env_flash_init(void) gd->env_valid =ENV_VALID ; }else if (!crc1_ok && !crc2_ok) { gd->env_addr = addr_default; - gd->env_valid =0 ; + gd->env_valid =ENV_INVALID ; }else if (flag1 ==ACTIVE_FLAG && flag2 ==OBSOLETE_FLAG ) { gd->env_addr = addr1; gd->env_valid =ENV_VALID ;
@@ -231,7 +231,7 @@ static int env_flash_init(void) } gd->env_addr = (ulong)&default_environment[0 ]; - gd->env_valid =0 ; + gd->env_valid =ENV_INVALID ;return 0 ; }#endif
env/nand.c +1 -1
@@ -79,7 +79,7 @@ static int env_nand_init(void)if (!crc1_ok && !crc2_ok) { gd->env_addr =0 ; - gd->env_valid =0 ; + gd->env_valid =ENV_INVALID ;return 0 ; }else if (crc1_ok && !crc2_ok) {
env/nvram.c +1 -1
@@ -106,7 +106,7 @@ static int env_nvram_init(void) gd->env_valid =ENV_VALID ; }else { gd->env_addr = (ulong)&default_environment[0 ]; - gd->env_valid =0 ; + gd->env_valid =ENV_INVALID ; }return 0 ;
Signature · 1 line
2.14.1.480.gb18f417b89-goog
PATCH 2/3 env: Allow env_load() to detect errors
In reply to Simon GlassQuoted 4 lines · Simon Glass
Now that we have errors available in the environment driver's
load()method, check the return valid.Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170820/098709e6/attachment.sig>
PATCH 3/3 env: Replace all open-coded gd->env_valid values with ENV_ flags
In reply to Simon GlassQuoted 2 lines · Simon Glass
Some of these were missed in the conversion.
Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170820/0cd398ed/attachment.sig>