From e1caa5841e8a9bc0ee658bdacae0519fa28e1e6a Mon Sep 17 00:00:00 2001 From: York Sun Date: Wed, 7 Feb 2018 14:17:11 -0800 Subject: 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 CC: Maxime Ripard --- env/env.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'env') diff --git a/env/env.c b/env/env.c index 9a89832..edfb575 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; -- cgit v1.1