summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYork Sun <york.sun@nxp.com>2018-02-08 01:17:11 +0300
committerTom Rini <trini@konsulko.com>2018-02-16 19:12:41 +0300
commite1caa5841e8a9bc0ee658bdacae0519fa28e1e6a (patch)
tree97f85fa34ef28e76d53a27eddd76fce321acb333
parent32fe36574ea5e6ea55313e16547b98a984af7767 (diff)
downloadu-boot-e1caa5841e8a9bc0ee658bdacae0519fa28e1e6a.tar.xz
env: Fix env_load_location
Commit 7d714a24d725 ("env: Support multiple environments") added static variable env_load_location. When saving environmental variables, this variable is presumed to have the value set before. In case the value was set before relocation and U-Boot runs from a NOR flash, this variable wasn't writable. This causes failure when saving the environment. To save this location, global data must be used instead. Signed-off-by: York Sun <york.sun@nxp.com> CC: Maxime Ripard <maxime.ripard@free-electrons.com>
-rw-r--r--env/env.c8
-rw-r--r--include/asm-generic/global_data.h1
-rw-r--r--include/environment.h2
3 files changed, 5 insertions, 6 deletions
diff --git a/env/env.c b/env/env.c
index 9a89832c1a..edfb575c0e 100644
--- a/env/env.c
+++ b/env/env.c
@@ -62,8 +62,6 @@ static enum env_location env_locations[] = {
#endif
};
-static enum env_location env_load_location = ENVL_UNKNOWN;
-
static bool env_has_inited(enum env_location location)
{
return gd->env_has_init & BIT(location);
@@ -108,11 +106,11 @@ __weak enum env_location env_get_location(enum env_operation op, int prio)
if (prio >= ARRAY_SIZE(env_locations))
return ENVL_UNKNOWN;
- env_load_location = env_locations[prio];
- return env_load_location;
+ gd->env_load_location = env_locations[prio];
+ return gd->env_load_location;
case ENVOP_SAVE:
- return env_load_location;
+ return gd->env_load_location;
}
return ENVL_UNKNOWN;
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index 1de67e8e8f..c16ad73864 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -51,6 +51,7 @@ typedef struct global_data {
unsigned long env_addr; /* Address of Environment struct */
unsigned long env_valid; /* Environment valid? enum env_valid */
unsigned long env_has_init; /* Bitmask of boolean of struct env_location offsets */
+ int env_load_location;
unsigned long ram_top; /* Top address of RAM used by U-Boot */
unsigned long relocaddr; /* Start address of U-Boot in RAM */
diff --git a/include/environment.h b/include/environment.h
index 6044b9e1b4..d7037ccd93 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -188,6 +188,7 @@ enum env_valid {
};
enum env_location {
+ ENVL_UNKNOWN,
ENVL_EEPROM,
ENVL_EXT4,
ENVL_FAT,
@@ -202,7 +203,6 @@ enum env_location {
ENVL_NOWHERE,
ENVL_COUNT,
- ENVL_UNKNOWN,
};
/* value for the various operations we want to perform on the env */