[U-Boot] [PATCH 01/11] env: fix ret not being set and fails when no env could have been init

Quentin Schulz quentin.schulz at free-electrons.com
Fri Dec 22 21:13:35 UTC 2017


This patch is fixing things that most likely will be done by Maxime in
the v2 of his patch series for multiple environments support, one way or
the other.

Signed-off-by: Quentin Schulz <quentin.schulz at free-electrons.com>
---
 env/env.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/env/env.c b/env/env.c
index 9b8b38c..5e70ddf 100644
--- a/env/env.c
+++ b/env/env.c
@@ -182,24 +182,25 @@ int env_init(void)
 	struct env_driver *drv;
 	int ret = -ENOENT;
 	int prio;
+	bool init = false;
 
 	for (prio = 0; (drv = env_driver_lookup(ENVO_INIT, prio)); prio++) {
-		if (!drv->init || !drv->init())
+		if (drv->init)
+			ret = drv->init(drv);
+		else
+			ret = 0;
+
+		if (!ret) {
 			gd->env_has_init |= BIT(drv->location);
+			init = true;
+		}
 
 		debug("%s: Environment %s init done (ret=%d)\n", __func__,
 		      drv->name, ret);
 	}
 
-	if (!prio)
+	if (!prio || !init)
 		return -ENODEV;
 
-	if (ret == -ENOENT) {
-		gd->env_addr = (ulong)&default_environment[0];
-		gd->env_valid = ENV_VALID;
-
-		return 0;
-	}
-
-	return ret;
+	return 0;
 }
-- 
git-series 0.9.1


More information about the U-Boot mailing list