From 46ce9e777c1314ccb78906992b94001194eaa87b Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Tue, 3 Nov 2020 15:22:36 +0100 Subject: env: sf: fix init function behaviour Michael wrote: commit 92765f45bb95 ("env: Access Environment in SPI flashes before relocation") at least breaks the Kontron sl28 board. I guess it also breaks others which use a (late) SPI environment. reason is, that env_init() sets the init bit, if there is no init function defined in an environment driver, and use default return value -ENOENT in this case later for setting the default environment. Change: Environment driver can now implement an init function and return, if this function does nothing, simply -ENOENT. env_init() now handles -ENOENT correct by setting the inited bit for the environment driver. And if there is no other environment driver whose init function returns 0, load than the default environment. This prevents that each environment driver needs to set the default environment. Fixes: 92765f45bb95 ("env: Access Environment in SPI flashes before relocation") Reported-by: Michael Walle Tested-by: Michael Walle [For the SF environment] Signed-off-by: Heiko Schocher --- env/env.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'env/env.c') diff --git a/env/env.c b/env/env.c index 42c7d81..37b4b54 100644 --- a/env/env.c +++ b/env/env.c @@ -329,6 +329,8 @@ int env_init(void) for (prio = 0; (drv = env_driver_lookup(ENVOP_INIT, prio)); prio++) { if (!drv->init || !(ret = drv->init())) env_set_inited(drv->location); + if (ret == -ENOENT) + env_set_inited(drv->location); debug("%s: Environment %s init done (ret=%d)\n", __func__, drv->name, ret); -- cgit v1.1