diff options
author | Rasmus Villemoes <rasmus.villemoes@prevas.dk> | 2021-04-14 20:51:42 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-04-16 11:55:55 -0400 |
commit | 4da7347d85aa4409945201279d71ae501cd5c164 (patch) | |
tree | 2f2636aa2a0012a97f67a8bfff4d33fb01803a76 /env | |
parent | 7cb977fd51b4ddcfe385749f035cc768a968edfb (diff) | |
download | u-boot-4da7347d85aa4409945201279d71ae501cd5c164.tar.gz u-boot-4da7347d85aa4409945201279d71ae501cd5c164.tar.bz2 u-boot-4da7347d85aa4409945201279d71ae501cd5c164.zip |
env/sf.c: use a variable to hold the sector size
As preparation for the next patch, use a local variable to represent
the sector size. No functional change.
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Diffstat (limited to 'env')
-rw-r--r-- | env/sf.c | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -73,6 +73,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(); @@ -93,8 +94,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) { @@ -107,11 +108,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; @@ -122,7 +123,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) @@ -187,6 +188,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; @@ -196,8 +198,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) @@ -213,11 +215,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; @@ -227,7 +229,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) |