MLK-22283 env: fix NAND ENV build issue introduced by env offset change
authorYe Li <ye.li@nxp.com>
Thu, 18 Jul 2019 06:14:59 +0000 (23:14 -0700)
committerYe Li <ye.li@nxp.com>
Thu, 18 Jul 2019 06:31:50 +0000 (23:31 -0700)
Get below build error in nand env, because we should not call function in
array initialization.

env/nand.c: In function ‘env_nand_save’:
env/nand.c:196:15: error: initializer element is not constant
.offset = env_get_offset(CONFIG_ENV_OFFSET),

Signed-off-by: Ye Li <ye.li@nxp.com>
(cherry picked from commit da33243320c9ebbde3f343aee7623028a440a024)

env/nand.c

index 5b444c3..078341c 100644 (file)
@@ -156,7 +156,7 @@ static int writeenv(size_t offset, u_char *buf)
 
 struct nand_env_location {
        const char *name;
-       const nand_erase_options_t erase_opts;
+       nand_erase_options_t erase_opts;
 };
 
 static int erase_and_write_env(const struct nand_env_location *location,
@@ -185,25 +185,17 @@ static int env_nand_save(void)
        int     ret = 0;
        ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
        int     env_idx = 0;
-       static const struct nand_env_location location[] = {
-               {
-                       .name = "NAND",
-                       .erase_opts = {
-                               .length = CONFIG_ENV_RANGE,
-                               .offset = env_get_offset(CONFIG_ENV_OFFSET),
-                       },
-               },
+       static struct nand_env_location location[2] = {0};
+
+       location[0].name = "NAND";
+       location[0].erase_opts.length = CONFIG_ENV_RANGE;
+       location[0].erase_opts.offset = env_get_offset(CONFIG_ENV_OFFSET);
+
 #ifdef CONFIG_ENV_OFFSET_REDUND
-               {
-                       .name = "redundant NAND",
-                       .erase_opts = {
-                               .length = CONFIG_ENV_RANGE,
-                               .offset = CONFIG_ENV_OFFSET_REDUND,
-                       },
-               },
+       location[1].name = "redundant NAND";
+       location[1].erase_opts.length = CONFIG_ENV_RANGE;
+       location[1].erase_opts.offset = CONFIG_ENV_OFFSET_REDUND;
 #endif
-       };
-
 
        if (CONFIG_ENV_RANGE < CONFIG_ENV_SIZE)
                return 1;