diff mbox series

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

Message ID 2e3c82fa00f6176931a315320b8724770575965a.1513975247.git-series.quentin.schulz@free-electrons.com
State New
Headers show
Series Introduce variables whitelisting in environment | expand

Commit Message

Quentin Schulz Dec. 22, 2017, 9:13 p.m. UTC
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@free-electrons.com>
---
 env/env.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
diff mbox series

Patch

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