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>
This commit is contained in:
18
env/flash.c
vendored
18
env/flash.c
vendored
@@ -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);
|
||||
|
Reference in New Issue
Block a user