[U-Boot] [PATCH] env: sf: fix return value of env_sf_load

Simon Goldschmidt sgoldschmidt at de.pepperl-fuchs.com
Tue Jan 30 08:15:09 UTC 2018


On 30.01.2018 08:55, Simon Goldschmidt wrote:
> With the recent changes to support multiple environments, I see a
> message "Failed (1)" when loading environment from sf.
>
> env_sf_load() returns the return value of env_import(). This must be
> 'inverted' to return the correct meaning.

Thinking about this again, it might be cleaner to make env_import and 
env_import_redundant return 0 on success. Would that be acceptable?

Regards,
Simon

>
> Signed-off-by: Simon Goldschmidt <sgoldschmidt at de.pepperl-fuchs.com>
> ---
>   env/sf.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/env/sf.c b/env/sf.c
> index a2e4c93631..921860fd88 100644
> --- a/env/sf.c
> +++ b/env/sf.c
> @@ -239,6 +239,9 @@ static int env_sf_load(void)
>   	if (!ret) {
>   		pr_err("Cannot import environment: errno = %d\n", errno);
>   		set_default_env("!env_import failed");
> +		ret = -EIO;
> +	} else {
> +		ret = 0;
>   	}
>   
>   err_read:
> @@ -336,8 +339,12 @@ static int env_sf_load(void)
>   	}
>   
>   	ret = env_import(buf, 1);
> -	if (ret)
> +	if (ret) {
>   		gd->env_valid = ENV_VALID;
> +		ret = 0;
> +	} else {
> +		ret = -EIO;
> +	}
>   
>   err_read:
>   	spi_flash_free(env_flash);



More information about the U-Boot mailing list