All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
To: u-boot@lists.denx.de
Subject: [PATCH 1/2] env/sf.c: use a variable to hold the sector size
Date: Fri, 18 Sep 2020 10:16:32 +0200	[thread overview]
Message-ID: <3ac16b9e-4665-7676-3ec0-02ca2852a4d3@prevas.dk> (raw)
In-Reply-To: <20200506084701.8076-2-rasmus.villemoes@prevas.dk>

On 06/05/2020 10.47, Rasmus Villemoes wrote:
> As preparation for the next patch, use a local variable to represent
> the sector size. No functional change.
> 

ping

> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> ---
>  env/sf.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/env/sf.c b/env/sf.c
> index 22b70ad319..cd5339578b 100644
> --- a/env/sf.c
> +++ b/env/sf.c
> @@ -70,6 +70,7 @@ static int env_sf_save(void)
>  	env_t	env_new;
>  	char	*saved_buffer = NULL, flag = ENV_REDUND_OBSOLETE;
>  	u32	saved_size, saved_offset, sector;
> +	u32	sect_size = CONFIG_ENV_SECT_SIZE;
>  	int	ret;
>  
>  	ret = setup_flash_device();
> @@ -90,8 +91,8 @@ static int env_sf_save(void)
>  	}
>  
>  	/* Is the sector larger than the env (i.e. embedded) */
> -	if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) {
> -		saved_size = CONFIG_ENV_SECT_SIZE - CONFIG_ENV_SIZE;
> +	if (sect_size > CONFIG_ENV_SIZE) {
> +		saved_size = sect_size - CONFIG_ENV_SIZE;
>  		saved_offset = env_new_offset + CONFIG_ENV_SIZE;
>  		saved_buffer = memalign(ARCH_DMA_MINALIGN, saved_size);
>  		if (!saved_buffer) {
> @@ -104,11 +105,11 @@ static int env_sf_save(void)
>  			goto done;
>  	}
>  
> -	sector = DIV_ROUND_UP(CONFIG_ENV_SIZE, CONFIG_ENV_SECT_SIZE);
> +	sector = DIV_ROUND_UP(CONFIG_ENV_SIZE, sect_size);
>  
>  	puts("Erasing SPI flash...");
>  	ret = spi_flash_erase(env_flash, env_new_offset,
> -				sector * CONFIG_ENV_SECT_SIZE);
> +				sector * sect_size);
>  	if (ret)
>  		goto done;
>  
> @@ -119,7 +120,7 @@ static int env_sf_save(void)
>  	if (ret)
>  		goto done;
>  
> -	if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) {
> +	if (sect_size > CONFIG_ENV_SIZE) {
>  		ret = spi_flash_write(env_flash, saved_offset,
>  					saved_size, saved_buffer);
>  		if (ret)
> @@ -184,6 +185,7 @@ out:
>  static int env_sf_save(void)
>  {
>  	u32	saved_size, saved_offset, sector;
> +	u32	sect_size = CONFIG_ENV_SECT_SIZE;
>  	char	*saved_buffer = NULL;
>  	int	ret = 1;
>  	env_t	env_new;
> @@ -193,8 +195,8 @@ static int env_sf_save(void)
>  		return ret;
>  
>  	/* Is the sector larger than the env (i.e. embedded) */
> -	if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) {
> -		saved_size = CONFIG_ENV_SECT_SIZE - CONFIG_ENV_SIZE;
> +	if (sect_size > CONFIG_ENV_SIZE) {
> +		saved_size = sect_size - CONFIG_ENV_SIZE;
>  		saved_offset = CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE;
>  		saved_buffer = malloc(saved_size);
>  		if (!saved_buffer)
> @@ -210,11 +212,11 @@ static int env_sf_save(void)
>  	if (ret)
>  		goto done;
>  
> -	sector = DIV_ROUND_UP(CONFIG_ENV_SIZE, CONFIG_ENV_SECT_SIZE);
> +	sector = DIV_ROUND_UP(CONFIG_ENV_SIZE, sect_size);
>  
>  	puts("Erasing SPI flash...");
>  	ret = spi_flash_erase(env_flash, CONFIG_ENV_OFFSET,
> -		sector * CONFIG_ENV_SECT_SIZE);
> +		sector * sect_size);
>  	if (ret)
>  		goto done;
>  
> @@ -224,7 +226,7 @@ static int env_sf_save(void)
>  	if (ret)
>  		goto done;
>  
> -	if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) {
> +	if (sect_size > CONFIG_ENV_SIZE) {
>  		ret = spi_flash_write(env_flash, saved_offset,
>  			saved_size, saved_buffer);
>  		if (ret)
> 


-- 
Rasmus Villemoes
Software Developer
Prevas A/S
Hedeager 3
DK-8200 Aarhus N
+45 51210274
rasmus.villemoes at prevas.dk
www.prevas.dk

  reply	other threads:[~2020-09-18  8:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06  8:46 [PATCH 0/2] add CONFIG_ENV_SECT_SIZE_AUTO Rasmus Villemoes
2020-05-06  8:47 ` [PATCH 1/2] env/sf.c: use a variable to hold the sector size Rasmus Villemoes
2020-09-18  8:16   ` Rasmus Villemoes [this message]
2020-09-18 14:49     ` Tom Rini
2020-05-06  8:47 ` [PATCH 2/2] env: add CONFIG_ENV_SECT_SIZE_AUTO Rasmus Villemoes
2020-05-06  8:59   ` Joakim Tjernlund
2020-05-06  9:11     ` Rasmus Villemoes
2020-05-06  9:21       ` Joakim Tjernlund
2020-05-06  9:37         ` Rasmus Villemoes
2020-05-06 10:00           ` Joakim Tjernlund
2020-05-06 10:15             ` Rasmus Villemoes
2020-05-06 10:22               ` Joakim Tjernlund
2020-05-06 10:18             ` Joakim Tjernlund
2020-05-06 10:47               ` Rasmus Villemoes
2020-05-06 11:06                 ` Joakim Tjernlund
2020-05-06 11:08                   ` Joakim Tjernlund
2020-09-18  8:17   ` Rasmus Villemoes
2020-09-24 10:54     ` Wolfgang Denk
2020-09-24 11:08       ` Rasmus Villemoes
     [not found]         ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.f435d534-2cba-4875-b180-3df85765465d@emailsignatures365.codetwo.com>
     [not found]           ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.0d2bd5fa-15cc-4b27-b94e-83614f9e5b38.1e7a7c88-825a-48b1-844c-973bce803cb6@emailsignatures365.codetwo.com>
2020-09-24 11:35             ` Mike Looijmans
2020-09-24 11:58               ` Rasmus Villemoes

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=3ac16b9e-4665-7676-3ec0-02ca2852a4d3@prevas.dk \
    --to=rasmus.villemoes@prevas.dk \
    --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.