diff mbox series

[v3,04/14] env: correctly handle env_load_prio

Message ID 20200625075958.9868-5-patrick.delaunay@st.com
State Changes Requested
Delegated to: Tom Rini
Headers show
Series env: ext4: corrections and add test for env in ext4 | expand

Commit Message

Patrick Delaunay June 25, 2020, 7:59 a.m. UTC
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>
---

Changes in v3:
- new

 env/env.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Tom Rini June 26, 2020, 8:55 p.m. UTC | #1
On Thu, Jun 25, 2020 at 09:59:48AM +0200, Patrick Delaunay wrote:

> 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>

Reviewed-by: Tom Rini <trini@konsulko.com>
diff mbox series

Patch

diff --git a/env/env.c b/env/env.c
index dcc25c030b..181aaa222c 100644
--- 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;
 }