
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.
Unfortunately, we cannot set the .init op and fall back to the same behavior as it would be unset. Thus guard the .init op by #if's.
Fixes: 92765f45bb95 ("env: Access Environment in SPI flashes before relocation") Signed-off-by: Michael Walle michael@walle.cc --- env/sf.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/env/sf.c b/env/sf.c index 2eb2de1a4e..18d44a7ddc 100644 --- a/env/sf.c +++ b/env/sf.c @@ -385,7 +385,7 @@ out: } #endif
-static int env_sf_init(void) +static int __maybe_unused env_sf_init(void) { #if defined(INITENV) && (CONFIG_ENV_ADDR != 0x0) return env_sf_init_addr(); @@ -393,8 +393,13 @@ 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() + * We shouldn't end up here. Unfortunately, there is no + * way to return a value which yields the same behavior + * as if the .init op wouldn't be set at all. See + * env_init(); env_set_inited() is only called if we + * return 0, but the default environment is only loaded + * if -ENOENT is returned. Therefore, we need the ugly + * ifdeferry for the .init op. */ return 0; } @@ -404,5 +409,7 @@ U_BOOT_ENV_LOCATION(sf) = { ENV_NAME("SPIFlash") .load = env_sf_load, .save = CONFIG_IS_ENABLED(SAVEENV) ? ENV_SAVE_PTR(env_sf_save) : NULL, +#if (defined(INITENV) && (CONFIG_ENV_ADDR != 0x0)) || defined(CONFIG_ENV_SPI_EARLY) .init = env_sf_init, +#endif };