Merge tag 'u-boot-stm32-20200310' of https://gitlab.denx.de/u-boot/custodians/u-boot-stm
[oweals/u-boot.git] / env / nand.c
index d0b95f483d34cc4649c39f53355587f3a277fd0c..8b0027d30472fe2cef56f13c95d2fcba739436c9 100644 (file)
 
 #include <common.h>
 #include <command.h>
-#include <environment.h>
+#include <env.h>
+#include <env_internal.h>
 #include <linux/stddef.h>
 #include <malloc.h>
 #include <memalign.h>
 #include <nand.h>
 #include <search.h>
 #include <errno.h>
+#include <u-boot/crc.h>
 
 #if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_NAND) && \
                !defined(CONFIG_SPL_BUILD)
 #error CONFIG_ENV_OFFSET_REDUND must have CONFIG_CMD_SAVEENV & CONFIG_CMD_NAND
 #endif
 
-#if defined(CONFIG_ENV_SIZE_REDUND) && \
-       (CONFIG_ENV_SIZE_REDUND != CONFIG_ENV_SIZE)
-#error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE
-#endif
-
 #ifndef CONFIG_ENV_RANGE
 #define CONFIG_ENV_RANGE       CONFIG_ENV_SIZE
 #endif
@@ -325,7 +322,7 @@ static int env_nand_load(void)
        tmp_env2 = (env_t *)malloc(CONFIG_ENV_SIZE);
        if (tmp_env1 == NULL || tmp_env2 == NULL) {
                puts("Can't allocate buffers for environment\n");
-               set_default_env("malloc() failed", 0);
+               env_set_default("malloc() failed", 0);
                ret = -EIO;
                goto done;
        }
@@ -364,14 +361,14 @@ static int env_nand_load(void)
        if (mtd && !get_nand_env_oob(mtd, &nand_env_oob_offset)) {
                printf("Found Environment offset in OOB..\n");
        } else {
-               set_default_env("no env offset in OOB", 0);
+               env_set_default("no env offset in OOB", 0);
                return;
        }
 #endif
 
        ret = readenv(CONFIG_ENV_OFFSET, (u_char *)buf);
        if (ret) {
-               set_default_env("readenv() failed", 0);
+               env_set_default("readenv() failed", 0);
                return -EIO;
        }