]> git.sur5r.net Git - u-boot/commitdiff
env: Replace all open-coded gd->env_valid values with ENV_ flags
authorSimon Glass <sjg@chromium.org>
Sun, 20 Aug 2017 10:45:15 +0000 (04:45 -0600)
committerTom Rini <trini@konsulko.com>
Sun, 20 Aug 2017 23:27:44 +0000 (19:27 -0400)
Some of these were missed in the conversion.
Signed-off-by: Simon Glass <sjg@chromium.org>
env/common.c
env/eeprom.c
env/env.c
env/flash.c
env/nand.c
env/nvram.c

index 688d5ab4c8985434288bc090d5797b95462eb96d..b403bd5f6c120f572df213978ca5cf2b0a9f774a 100644 (file)
@@ -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);
index 08ef6307fc5c672ed7a814757cd7bef090b97361..584379ebd26e3673ffd2d4055640160d24108582 100644 (file)
@@ -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 */
 
index 1255d57f48d29ece6a668cc85c41c0c3cc8d1d08..43290d0832125f7ad98f78ec5df8db51b8689207 100644 (file)
--- a/env/env.c
+++ b/env/env.c
@@ -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;
index b60be57a8dd1585bcc9edb895e9d00dce1f4d789..bac10ff98561232e88adeba9f83f70f6e9ce43cb 100644 (file)
@@ -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
index dea7b00720ef9fbb11309abfda326f11d8568aa5..8058b55c502992540b44b236f625c452fb045b61 100644 (file)
@@ -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) {
index 5fb3115ce65af3db82429e8311c3d507adc6fa47..c8b34754efc692690ad3510eb9f790d708b2a72e 100644 (file)
@@ -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;