diff options
author | Simon Glass | 2017-08-03 12:21:56 -0600 |
---|---|---|
committer | Tom Rini | 2017-08-15 08:18:51 -0400 |
commit | 203e94f6c9ca03e260175ce240f5856507395585 (patch) | |
tree | 1b13b0ff87c4117e18e6ee7db97e09c541724b69 /env/flash.c | |
parent | 75de597d2d91b1102584d4b641daf592d894207e (diff) |
env: Add an enum for environment state
At present we have three states for the environment, numbered 0, 1 and 2.
Add an enum to record this to avoid open-coded values.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'env/flash.c')
-rw-r--r-- | env/flash.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/env/flash.c b/env/flash.c index 004e8849a7d..dcf3cd2c62c 100644 --- a/env/flash.c +++ b/env/flash.c @@ -75,28 +75,28 @@ int env_init(void) if (crc1_ok && !crc2_ok) { gd->env_addr = addr1; - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } else if (!crc1_ok && crc2_ok) { gd->env_addr = addr2; - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } else if (!crc1_ok && !crc2_ok) { gd->env_addr = addr_default; gd->env_valid = 0; } else if (flag1 == ACTIVE_FLAG && flag2 == OBSOLETE_FLAG) { gd->env_addr = addr1; - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } else if (flag1 == OBSOLETE_FLAG && flag2 == ACTIVE_FLAG) { gd->env_addr = addr2; - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } else if (flag1 == flag2) { gd->env_addr = addr1; - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; } else if (flag1 == 0xFF) { gd->env_addr = addr1; - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; } else if (flag2 == 0xFF) { gd->env_addr = addr2; - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; } return 0; @@ -211,7 +211,7 @@ int env_init(void) { if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) { gd->env_addr = (ulong)&(env_ptr->data); - gd->env_valid = 1; + gd->env_valid = ENV_VALID; return 0; } @@ -309,7 +309,7 @@ void env_relocate_spec(void) crc32(0, flash_addr_new->data, ENV_SIZE) == flash_addr_new->crc) { char flag = OBSOLETE_FLAG; - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; flash_sect_protect(0, (ulong)flash_addr_new, end_addr_new); flash_write(&flag, (ulong)&(flash_addr_new->flags), @@ -321,7 +321,7 @@ void env_relocate_spec(void) (flash_addr->flags & ACTIVE_FLAG) == ACTIVE_FLAG) { char flag = ACTIVE_FLAG; - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; flash_sect_protect(0, (ulong)flash_addr, end_addr); flash_write(&flag, (ulong)&(flash_addr->flags), @@ -329,7 +329,7 @@ void env_relocate_spec(void) flash_sect_protect(1, (ulong)flash_addr, end_addr); } - if (gd->env_valid == 2) + if (gd->env_valid == ENV_REDUND) puts("*** Warning - some problems detected " "reading environment; recovered successfully\n\n"); #endif /* CONFIG_ENV_ADDR_REDUND */ |