aboutsummaryrefslogtreecommitdiff
path: root/env
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-08-01 09:47:08 -0600
committerTom Rini <trini@konsulko.com>2019-08-11 16:43:41 -0400
commitd3716dd64bb8bb4c4ba2d19bac164d24ada72a68 (patch)
tree0813ae10d149c97f5dedb88624366dff087dcd05 /env
parent25e51e90feec10b7d534b123cd9c4ed7a3a2dc1a (diff)
downloadu-boot-d3716dd64bb8bb4c4ba2d19bac164d24ada72a68.zip
u-boot-d3716dd64bb8bb4c4ba2d19bac164d24ada72a68.tar.gz
u-boot-d3716dd64bb8bb4c4ba2d19bac164d24ada72a68.tar.bz2
env: Rename the redundancy flags
Add an ENV prefix to these two flags so that it is clear what they relate to. Also move them to env.h since they are part of the public API. Use an enum rather than a #define to tie them together. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'env')
-rw-r--r--env/eeprom.c10
-rw-r--r--env/flash.c18
-rw-r--r--env/sf.c6
3 files changed, 18 insertions, 16 deletions
diff --git a/env/eeprom.c b/env/eeprom.c
index 8d82cf8..91ee3f3 100644
--- a/env/eeprom.c
+++ b/env/eeprom.c
@@ -132,9 +132,11 @@ static int env_eeprom_load(void)
gd->env_valid = ENV_REDUND;
} else {
/* both ok - check serial */
- if (flags[0] == ACTIVE_FLAG && flags[1] == OBSOLETE_FLAG)
+ if (flags[0] == ENV_REDUND_ACTIVE &&
+ flags[1] == ENV_REDUND_OBSOLETE)
gd->env_valid = ENV_VALID;
- else if (flags[0] == OBSOLETE_FLAG && flags[1] == ACTIVE_FLAG)
+ else if (flags[0] == ENV_REDUND_OBSOLETE &&
+ flags[1] == ENV_REDUND_ACTIVE)
gd->env_valid = ENV_REDUND;
else if (flags[0] == 0xFF && flags[1] == 0)
gd->env_valid = ENV_REDUND;
@@ -194,7 +196,7 @@ static int env_eeprom_save(void)
unsigned int off = CONFIG_ENV_OFFSET;
#ifdef CONFIG_ENV_OFFSET_REDUND
unsigned int off_red = CONFIG_ENV_OFFSET_REDUND;
- char flag_obsolete = OBSOLETE_FLAG;
+ char flag_obsolete = ENV_REDUND_OBSOLETE;
#endif
rc = env_export(&env_new);
@@ -207,7 +209,7 @@ static int env_eeprom_save(void)
off_red = CONFIG_ENV_OFFSET;
}
- env_new.flags = ACTIVE_FLAG;
+ env_new.flags = ENV_REDUND_ACTIVE;
#endif
rc = eeprom_bus_write(CONFIG_SYS_DEF_EEPROM_ADDR,
diff --git a/env/flash.c b/env/flash.c
index 7a73466..bdba09e 100644
--- a/env/flash.c
+++ b/env/flash.c
@@ -95,10 +95,12 @@ static int env_flash_init(void)
} else if (!crc1_ok && !crc2_ok) {
gd->env_addr = addr_default;
gd->env_valid = ENV_INVALID;
- } else if (flag1 == ACTIVE_FLAG && flag2 == OBSOLETE_FLAG) {
+ } else if (flag1 == ENV_REDUND_ACTIVE &&
+ flag2 == ENV_REDUND_OBSOLETE) {
gd->env_addr = addr1;
gd->env_valid = ENV_VALID;
- } else if (flag1 == OBSOLETE_FLAG && flag2 == ACTIVE_FLAG) {
+ } else if (flag1 == ENV_REDUND_OBSOLETE &&
+ flag2 == ENV_REDUND_ACTIVE) {
gd->env_addr = addr2;
gd->env_valid = ENV_VALID;
} else if (flag1 == flag2) {
@@ -121,7 +123,7 @@ static int env_flash_save(void)
{
env_t env_new;
char *saved_data = NULL;
- char flag = OBSOLETE_FLAG, new_flag = ACTIVE_FLAG;
+ char flag = ENV_REDUND_OBSOLETE, new_flag = ENV_REDUND_ACTIVE;
int rc = 1;
#if CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE
ulong up_data = 0;
@@ -322,9 +324,9 @@ static int env_flash_load(void)
end_addr_new = ltmp;
}
- if (flash_addr_new->flags != OBSOLETE_FLAG &&
+ if (flash_addr_new->flags != ENV_REDUND_OBSOLETE &&
crc32(0, flash_addr_new->data, ENV_SIZE) == flash_addr_new->crc) {
- char flag = OBSOLETE_FLAG;
+ char flag = ENV_REDUND_OBSOLETE;
gd->env_valid = ENV_REDUND;
flash_sect_protect(0, (ulong)flash_addr_new, end_addr_new);
@@ -334,9 +336,9 @@ static int env_flash_load(void)
flash_sect_protect(1, (ulong)flash_addr_new, end_addr_new);
}
- if (flash_addr->flags != ACTIVE_FLAG &&
- (flash_addr->flags & ACTIVE_FLAG) == ACTIVE_FLAG) {
- char flag = ACTIVE_FLAG;
+ if (flash_addr->flags != ENV_REDUND_ACTIVE &&
+ (flash_addr->flags & ENV_REDUND_ACTIVE) == ENV_REDUND_ACTIVE) {
+ char flag = ENV_REDUND_ACTIVE;
gd->env_valid = ENV_REDUND;
flash_sect_protect(0, (ulong)flash_addr, end_addr);
diff --git a/env/sf.c b/env/sf.c
index 5531293..09646e1 100644
--- a/env/sf.c
+++ b/env/sf.c
@@ -30,8 +30,6 @@ static ulong env_offset = CONFIG_ENV_OFFSET;
static ulong env_new_offset = CONFIG_ENV_OFFSET_REDUND;
#endif
-#define ACTIVE_FLAG 1
-#define OBSOLETE_FLAG 0
#endif /* CONFIG_ENV_OFFSET_REDUND */
DECLARE_GLOBAL_DATA_PTR;
@@ -74,7 +72,7 @@ static int setup_flash_device(void)
static int env_sf_save(void)
{
env_t env_new;
- char *saved_buffer = NULL, flag = OBSOLETE_FLAG;
+ char *saved_buffer = NULL, flag = ENV_REDUND_OBSOLETE;
u32 saved_size, saved_offset, sector;
int ret;
@@ -85,7 +83,7 @@ static int env_sf_save(void)
ret = env_export(&env_new);
if (ret)
return -EIO;
- env_new.flags = ACTIVE_FLAG;
+ env_new.flags = ENV_REDUND_ACTIVE;
if (gd->env_valid == ENV_VALID) {
env_new_offset = CONFIG_ENV_OFFSET_REDUND;