]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - env/nand.c
imx: hab: Check if CSF contains deprecated commands
[people/ms/u-boot.git] / env / nand.c
index dea7b00720ef9fbb11309abfda326f11d8568aa5..904f1c40d6229c877d27b543fd03e4b1d022ca2a 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) {
@@ -320,7 +320,7 @@ static int env_nand_load(void)
 #if defined(ENV_IS_EMBEDDED)
        return 0;
 #else
-       int read1_fail = 0, read2_fail = 0;
+       int read1_fail, read2_fail;
        env_t *tmp_env1, *tmp_env2;
        int ret = 0;
 
@@ -336,24 +336,8 @@ static int env_nand_load(void)
        read1_fail = readenv(CONFIG_ENV_OFFSET, (u_char *) tmp_env1);
        read2_fail = readenv(CONFIG_ENV_OFFSET_REDUND, (u_char *) tmp_env2);
 
-       if (read1_fail && read2_fail)
-               puts("*** Error - No Valid Environment Area found\n");
-       else if (read1_fail || read2_fail)
-               puts("*** Warning - some problems detected "
-                    "reading environment; recovered successfully\n");
-
-       if (read1_fail && read2_fail) {
-               set_default_env("!bad env area");
-               goto done;
-       } else if (!read1_fail && read2_fail) {
-               gd->env_valid = ENV_VALID;
-               env_import((char *)tmp_env1, 1);
-       } else if (read1_fail && !read2_fail) {
-               gd->env_valid = ENV_REDUND;
-               env_import((char *)tmp_env2, 1);
-       } else {
-               env_import_redund((char *)tmp_env1, (char *)tmp_env2);
-       }
+       ret = env_import_redund((char *)tmp_env1, read1_fail, (char *)tmp_env2,
+                               read2_fail);
 
 done:
        free(tmp_env1);
@@ -394,7 +378,7 @@ static int env_nand_load(void)
                return -EIO;
        }
 
-       env_import(buf, 1);
+       return env_import(buf, 1);
 #endif /* ! ENV_IS_EMBEDDED */
 
        return 0;