public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@bootlin.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] env: Fix env_load_location
Date: Thu, 8 Feb 2018 09:38:05 +0100	[thread overview]
Message-ID: <20180208083805.cpltz66wp32d4qzv@flea> (raw)
In-Reply-To: <1518041832-337-1-git-send-email-york.sun@nxp.com>

Hi,

Thanks for your patch

On Wed, Feb 07, 2018 at 02:17:11PM -0800, York Sun wrote:
> Commit 7d714a24d725 ("env: Support multiple environments") added
> static variable env_load_location. When saving environmental
> variables, this variable is presumed to have the value set before.
> In case the value was set before relocation and U-Boot runs from a
> NOR flash, this variable wasn't writable. This causes failure when
> saving the environment. To save this location, global data must be
> used instead.
> 
> Signed-off-by: York Sun <york.sun@nxp.com>
> CC: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
> Limited test on LS1043ARDB.
> 
>  env/env.c                         | 8 +++-----
>  include/asm-generic/global_data.h | 1 +
>  include/environment.h             | 2 +-
>  3 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/env/env.c b/env/env.c
> index 9a89832..edfb575 100644
> --- a/env/env.c
> +++ b/env/env.c
> @@ -62,8 +62,6 @@ static enum env_location env_locations[] = {
>  #endif
>  };
>  
> -static enum env_location env_load_location = ENVL_UNKNOWN;
> -
>  static bool env_has_inited(enum env_location location)
>  {
>  	return gd->env_has_init & BIT(location);
> @@ -108,11 +106,11 @@ __weak enum env_location env_get_location(enum env_operation op, int prio)
>  		if (prio >= ARRAY_SIZE(env_locations))
>  			return ENVL_UNKNOWN;
>  
> -		env_load_location = env_locations[prio];
> -		return env_load_location;
> +		gd->env_load_location = env_locations[prio];
> +		return gd->env_load_location;
>  
>  	case ENVOP_SAVE:
> -		return env_load_location;
> +		return gd->env_load_location;
>  	}
>  
>  	return ENVL_UNKNOWN;
> diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
> index fd8cd45..10f1441 100644
> --- a/include/asm-generic/global_data.h
> +++ b/include/asm-generic/global_data.h
> @@ -51,6 +51,7 @@ typedef struct global_data {
>  	unsigned long env_addr;		/* Address  of Environment struct */
>  	unsigned long env_valid;	/* Environment valid? enum env_valid */
>  	unsigned long env_has_init;	/* Bitmask of boolean of struct env_location offsets */
> +	int env_load_location;
>  
>  	unsigned long ram_top;		/* Top address of RAM used by U-Boot */
>  	unsigned long relocaddr;	/* Start address of U-Boot in RAM */
> diff --git a/include/environment.h b/include/environment.h
> index a406050..0f339da 100644
> --- a/include/environment.h
> +++ b/include/environment.h
> @@ -188,6 +188,7 @@ enum env_valid {
>  };
>  
>  enum env_location {
> +	ENVL_UNKNOWN,
>  	ENVL_EEPROM,
>  	ENVL_EXT4,
>  	ENVL_FAT,
> @@ -202,7 +203,6 @@ enum env_location {
>  	ENVL_NOWHERE,
>  
>  	ENVL_COUNT,
> -	ENVL_UNKNOWN,

Why did you need to change this? This looks a bit odd.

Thanks!
Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180208/8f54ce1f/attachment.sig>

  parent reply	other threads:[~2018-02-08  8:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-07 22:17 [U-Boot] [PATCH 1/2] env: Fix env_load_location York Sun
2018-02-07 22:17 ` [U-Boot] [PATCH 2/2] env: Add back default action of get_char in env_get_char() York Sun
2018-02-08  8:47   ` Maxime Ripard
2018-02-08  9:42     ` Simon Goldschmidt
2018-02-08  9:43       ` Simon Goldschmidt
2018-02-08  9:52     ` Simon Goldschmidt
2018-02-08 22:10       ` Maxime Ripard
2018-02-09 20:25         ` Goldschmidt Simon
2018-02-08  8:38 ` Maxime Ripard [this message]
2018-02-08 10:05   ` [U-Boot] [PATCH 1/2] env: Fix env_load_location Simon Goldschmidt
2018-02-08 19:28     ` York Sun
2018-02-17 20:51 ` [U-Boot] [U-Boot,1/2] " 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=20180208083805.cpltz66wp32d4qzv@flea \
    --to=maxime.ripard@bootlin.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox