From 203e94f6c9ca03e260175ce240f5856507395585 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 3 Aug 2017 12:21:56 -0600 Subject: 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 Reviewed-by: Tom Rini --- env/flash.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'env/flash.c') 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 */ -- cgit v1.2.3