]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
env: correctly handle env_load_prio
authorPatrick Delaunay <patrick.delaunay@st.com>
Tue, 28 Jul 2020 09:51:17 +0000 (11:51 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 31 Jul 2020 14:13:00 +0000 (10:13 -0400)
Only update gd->env_load_prio in generic function env_load()
and no more in the weak function env_get_location() which is
called in many place (for example in env_driver_lookup, even
for ENVOP_SAVE operation).

This patch is a preliminary step to use env_driver_lookup()/
env_get_location() in new function env_select() without
updating gd->env_load_prio.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
env/env.c

index 2e64346438e884bdd9996b69f6664843aa35afd9..bcc68c6bcefb82fd559b5c54d00e40466dd86ff5 100644 (file)
--- a/env/env.c
+++ b/env/env.c
@@ -131,8 +131,6 @@ __weak enum env_location env_get_location(enum env_operation op, int prio)
        if (prio >= ARRAY_SIZE(env_locations))
                return ENVL_UNKNOWN;
 
-       gd->env_load_prio = prio;
-
        return env_locations[prio];
 }
 
@@ -204,6 +202,8 @@ int env_load(void)
                ret = drv->load();
                if (!ret) {
                        printf("OK\n");
+                       gd->env_load_prio = prio;
+
                        return 0;
                } else if (ret == -ENOMSG) {
                        /* Handle "bad CRC" case */
@@ -227,7 +227,8 @@ int env_load(void)
                debug("Selecting environment with bad CRC\n");
        else
                best_prio = 0;
-       env_get_location(ENVOP_LOAD, best_prio);
+
+       gd->env_load_prio = best_prio;
 
        return -ENODEV;
 }