All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] env: common: Return specific error code on bad CRC
Date: Mon, 21 Jan 2019 14:36:38 +0100	[thread overview]
Message-ID: <825259b0-0fe3-8862-3235-c50ee0fe632e@gmail.com> (raw)
In-Reply-To: <20190118191904.634-2-semen.protsenko@linaro.org>

Am 18.01.2019 um 20:19 schrieb Sam Protsenko:
> Callers of env_import*() functions might want to check the case when we
> have incorrect environment (with bad CRC). For example, when environment
> location is being defined in env_load(), call chain may look like this:
> 
>      env_load() -> drv->load() = env_mmc_load() -> env_import()
> 
> Return code will be passed from env_import() all way up to env_load().
> Right now both env_mmc_load() and env_import() return -EIO error code,
> so env_load() can't differentiate between two cases:
>    1. Driver reports the error, because device is not accessible
>    2. Device is actually accessible, but environment is broken
> 
> Let's return -ENOMSG in env_import(), so we can distinguish two cases
> mentioned above. It will make it possible to continue working with "bad
> CRC" environment (like doing "env save"), instead of considering it not
> functional (implemented in subsequent patch).
> 
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>

Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>

> ---
>   env/common.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/env/common.c b/env/common.c
> index d1a6a52860..324502ed82 100644
> --- a/env/common.c
> +++ b/env/common.c
> @@ -115,7 +115,7 @@ int env_import(const char *buf, int check)
>   
>   		if (crc32(0, ep->data, ENV_SIZE) != crc) {
>   			set_default_env("bad CRC", 0);
> -			return -EIO;
> +			return -ENOMSG; /* needed for env_load() */
>   		}
>   	}
>   
> @@ -169,7 +169,7 @@ int env_import_redund(const char *buf1, int buf1_read_fail,
>   
>   	if (!crc1_ok && !crc2_ok) {
>   		set_default_env("bad CRC", 0);
> -		return -EIO;
> +		return -ENOMSG; /* needed for env_load() */
>   	} else if (crc1_ok && !crc2_ok) {
>   		gd->env_valid = ENV_VALID;
>   	} else if (!crc1_ok && crc2_ok) {
> 

  reply	other threads:[~2019-01-21 13:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-18 19:19 [U-Boot] [PATCH 0/2] env: Fix "env save" to malformed environment Sam Protsenko
2019-01-18 19:19 ` [U-Boot] [PATCH 1/2] env: common: Return specific error code on bad CRC Sam Protsenko
2019-01-21 13:36   ` Simon Goldschmidt [this message]
2019-01-27  3:53   ` [U-Boot] [U-Boot, " Tom Rini
2019-01-18 19:19 ` [U-Boot] [PATCH 2/2] env: Fix saving environment to "bad CRC" location Sam Protsenko
2019-01-18 20:46   ` Simon Goldschmidt
2019-01-19 13:28     ` Sam Protsenko
2019-01-21  9:18       ` Simon Goldschmidt
2019-01-21 13:36         ` Simon Goldschmidt
2019-01-24 14:11   ` Frank Wunderlich
2019-01-25 15:03     ` Sam Protsenko
2019-01-27  3:53   ` [U-Boot] [U-Boot, " Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=825259b0-0fe3-8862-3235-c50ee0fe632e@gmail.com \
    --to=simon.k.r.goldschmidt@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.