env: sf: fix init function behaviour
PATCH 1/1 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.
---
travis build:
https://travis-ci.org/github/hsdenx/u-boot-test/builds/741049813
env/env.c | 2 ++ env/sf.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-)
env/env.c +2 -0
@@ -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);
env/sf.c +5 -3
@@ -393,10 +393,12 @@ static int env_sf_init(void)return env_sf_init_early ();#endif /* -* we must return with 0 if there is nothing done, -* else env_set_inited() get not called in env_init() +* return here -ENOENT, so env_init() +* can set the init bit and later if no +* other Environment storage is defined +* can set the default environment */ -return 0 ; +return -ENOENT ; }U_BOOT_ENV_LOCATION (sf) = {
Signature · 1 line
2.25.4
PATCH 1/1 env: sf: fix init function behaviour
Am 2020-11-03 15:22, schrieb Heiko Schocher:
Quoted 20 lines
Michael wrote:
commit92765f45bb95("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-ENOENTin 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-ENOENTcorrect 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.
Quoted 7 lines
This prevents that each environment driver needs to set the default environment.
Fixes 92765f45bb95 ("env: Access Environment in SPI flashes beforerelocation")
Reported-by Michael Walle <[email protected]>Signed-off-by Heiko Schocher <[email protected]>
For the SF environment:
Thanks,
-michael
PATCH 1/1 env: sf: fix init function behaviour
In reply to Heiko SchocherQuoted 20 lines · Heiko Schocher
Michael wrote:
commit92765f45bb95("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-ENOENTin 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-ENOENTcorrect 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.
Quoted 7 lines
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 <[email protected]>Signed-off-by Heiko Schocher <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201103/142c428d/attachment.sig>