diff options
author | Simon Glass <sjg@chromium.org> | 2017-08-03 12:21:56 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-08-15 08:18:51 -0400 |
commit | 203e94f6c9ca03e260175ce240f5856507395585 (patch) | |
tree | 1b13b0ff87c4117e18e6ee7db97e09c541724b69 /env/sf.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/sf.c')
-rw-r--r-- | env/sf.c | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -93,7 +93,7 @@ int saveenv(void) return ret; env_new.flags = ACTIVE_FLAG; - if (gd->env_valid == 1) { + if (gd->env_valid == ENV_VALID) { env_new_offset = CONFIG_ENV_OFFSET_REDUND; env_offset = CONFIG_ENV_OFFSET; } else { @@ -145,7 +145,7 @@ int saveenv(void) puts("done\n"); - gd->env_valid = gd->env_valid == 2 ? 1 : 2; + gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : ENV_REDUND; printf("Valid environment: %d\n", (int)gd->env_valid); @@ -198,30 +198,30 @@ void env_relocate_spec(void) set_default_env("!bad CRC"); goto err_read; } else if (crc1_ok && !crc2_ok) { - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } else if (!crc1_ok && crc2_ok) { - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; } else if (tmp_env1->flags == ACTIVE_FLAG && tmp_env2->flags == OBSOLETE_FLAG) { - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } else if (tmp_env1->flags == OBSOLETE_FLAG && tmp_env2->flags == ACTIVE_FLAG) { - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; } else if (tmp_env1->flags == tmp_env2->flags) { - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } else if (tmp_env1->flags == 0xFF) { - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } else if (tmp_env2->flags == 0xFF) { - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; } else { /* * this differs from code in env_flash.c, but I think a sane * default path is desirable. */ - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } - if (gd->env_valid == 1) + if (gd->env_valid == ENV_VALID) ep = tmp_env1; else ep = tmp_env2; @@ -324,7 +324,7 @@ void env_relocate_spec(void) ret = env_import(buf, 1); if (ret) - gd->env_valid = 1; + gd->env_valid = ENV_VALID; err_read: spi_flash_free(env_flash); @@ -338,7 +338,7 @@ int env_init(void) { /* SPI flash isn't usable before relocation */ gd->env_addr = (ulong)&default_environment[0]; - gd->env_valid = 1; + gd->env_valid = ENV_VALID; return 0; } |