diff options
Diffstat (limited to 'env')
-rw-r--r-- | env/dataflash.c | 2 | ||||
-rw-r--r-- | env/eeprom.c | 30 | ||||
-rw-r--r-- | env/ext4.c | 2 | ||||
-rw-r--r-- | env/fat.c | 2 | ||||
-rw-r--r-- | env/flash.c | 22 | ||||
-rw-r--r-- | env/mmc.c | 10 | ||||
-rw-r--r-- | env/nand.c | 29 | ||||
-rw-r--r-- | env/nvram.c | 2 | ||||
-rw-r--r-- | env/onenand.c | 4 | ||||
-rw-r--r-- | env/remote.c | 2 | ||||
-rw-r--r-- | env/sata.c | 2 | ||||
-rw-r--r-- | env/sf.c | 26 | ||||
-rw-r--r-- | env/ubi.c | 6 |
13 files changed, 70 insertions, 69 deletions
diff --git a/env/dataflash.c b/env/dataflash.c index 034e323..c140b74 100644 --- a/env/dataflash.c +++ b/env/dataflash.c @@ -78,7 +78,7 @@ int env_init(void) { /* use default */ gd->env_addr = (ulong)&default_environment[0]; - gd->env_valid = 1; + gd->env_valid = ENV_VALID; return 0; } diff --git a/env/eeprom.c b/env/eeprom.c index 5f63a6c..ac6b30f 100644 --- a/env/eeprom.c +++ b/env/eeprom.c @@ -71,7 +71,7 @@ uchar env_get_char_spec(int index) unsigned int off = CONFIG_ENV_OFFSET; #ifdef CONFIG_ENV_OFFSET_REDUND - if (gd->env_valid == 2) + if (gd->env_valid == ENV_REDUND) off = CONFIG_ENV_OFFSET_REDUND; #endif eeprom_bus_read(CONFIG_SYS_DEF_EEPROM_ADDR, @@ -128,21 +128,21 @@ void env_relocate_spec(void) gd->env_addr = 0; gd->env_valid = 0; } else if (crc_ok[0] && !crc_ok[1]) { - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } else if (!crc_ok[0] && crc_ok[1]) { - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; } else { /* both ok - check serial */ if (flags[0] == ACTIVE_FLAG && flags[1] == OBSOLETE_FLAG) - gd->env_valid = 1; + gd->env_valid = ENV_VALID; else if (flags[0] == OBSOLETE_FLAG && flags[1] == ACTIVE_FLAG) - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; else if (flags[0] == 0xFF && flags[1] == 0) - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; else if (flags[1] == 0xFF && flags[0] == 0) - gd->env_valid = 1; + gd->env_valid = ENV_VALID; else /* flags are equal - almost impossible */ - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } #else /* CONFIG_ENV_OFFSET_REDUND */ @@ -170,7 +170,7 @@ void env_relocate_spec(void) } if (crc == new) { - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } else { gd->env_valid = 0; } @@ -178,7 +178,7 @@ void env_relocate_spec(void) off = CONFIG_ENV_OFFSET; #ifdef CONFIG_ENV_OFFSET_REDUND - if (gd->env_valid == 2) + if (gd->env_valid == ENV_REDUND) off = CONFIG_ENV_OFFSET_REDUND; #endif @@ -205,7 +205,7 @@ int saveenv(void) return rc; #ifdef CONFIG_ENV_OFFSET_REDUND - if (gd->env_valid == 1) { + if (gd->env_valid == ENV_VALID) { off = CONFIG_ENV_OFFSET_REDUND; off_red = CONFIG_ENV_OFFSET; } @@ -222,10 +222,10 @@ int saveenv(void) off_red + offsetof(env_t, flags), (uchar *)&flag_obsolete, 1); - if (gd->env_valid == 1) - gd->env_valid = 2; + if (gd->env_valid == ENV_VALID) + gd->env_valid = ENV_REDUND; else - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } #endif return rc; @@ -240,6 +240,6 @@ int saveenv(void) int env_init(void) { gd->env_addr = (ulong)&default_environment[0]; - gd->env_valid = 1; + gd->env_valid = ENV_VALID; return 0; } @@ -41,7 +41,7 @@ int env_init(void) { /* use default */ gd->env_addr = (ulong)&default_environment[0]; - gd->env_valid = 1; + gd->env_valid = ENV_VALID; return 0; } @@ -29,7 +29,7 @@ int env_init(void) { /* use default */ gd->env_addr = (ulong)&default_environment[0]; - gd->env_valid = 1; + gd->env_valid = ENV_VALID; return 0; } diff --git a/env/flash.c b/env/flash.c index 004e884..dcf3cd2 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 */ @@ -86,7 +86,7 @@ int env_init(void) { /* use default */ gd->env_addr = (ulong)&default_environment[0]; - gd->env_valid = 1; + gd->env_valid = ENV_VALID; return 0; } @@ -180,7 +180,7 @@ int saveenv(void) goto fini; #ifdef CONFIG_ENV_OFFSET_REDUND - if (gd->env_valid == 1) + if (gd->env_valid == ENV_VALID) copy = 1; #endif @@ -200,7 +200,7 @@ int saveenv(void) ret = 0; #ifdef CONFIG_ENV_OFFSET_REDUND - gd->env_valid = gd->env_valid == 2 ? 1 : 2; + gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : ENV_REDUND; #endif fini: @@ -265,10 +265,10 @@ void env_relocate_spec(void) ret = 1; goto fini; } else if (!read1_fail && read2_fail) { - gd->env_valid = 1; + gd->env_valid = ENV_VALID; env_import((char *)tmp_env1, 1); } else if (read1_fail && !read2_fail) { - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; env_import((char *)tmp_env2, 1); } else { env_import_redund((char *)tmp_env1, (char *)tmp_env2); @@ -84,37 +84,37 @@ int env_init(void) return 0; } else if (crc1_ok && !crc2_ok) { - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } #ifdef CONFIG_ENV_OFFSET_REDUND else if (!crc1_ok && crc2_ok) { - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; } else { /* both ok - check serial */ if (tmp_env1->flags == 255 && tmp_env2->flags == 0) - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; else if (tmp_env2->flags == 255 && tmp_env1->flags == 0) - gd->env_valid = 1; + gd->env_valid = ENV_VALID; else if (tmp_env1->flags > tmp_env2->flags) - gd->env_valid = 1; + gd->env_valid = ENV_VALID; else if (tmp_env2->flags > tmp_env1->flags) - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; else /* flags are equal - almost impossible */ - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } - if (gd->env_valid == 2) + if (gd->env_valid == ENV_REDUND) env_ptr = tmp_env2; else #endif - if (gd->env_valid == 1) + if (gd->env_valid == ENV_VALID) env_ptr = tmp_env1; gd->env_addr = (ulong)env_ptr->data; #else /* ENV_IS_EMBEDDED || CONFIG_NAND_ENV_DST */ gd->env_addr = (ulong)&default_environment[0]; - gd->env_valid = 1; + gd->env_valid = ENV_VALID; #endif /* ENV_IS_EMBEDDED || CONFIG_NAND_ENV_DST */ return 0; @@ -217,14 +217,15 @@ int saveenv(void) return ret; #ifdef CONFIG_ENV_OFFSET_REDUND - env_idx = (gd->env_valid == 1); + env_idx = (gd->env_valid == ENV_VALID); #endif ret = erase_and_write_env(&location[env_idx], (u_char *)env_new); #ifdef CONFIG_ENV_OFFSET_REDUND if (!ret) { /* preset other copy for next write */ - gd->env_valid = gd->env_valid == 2 ? 1 : 2; + gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : + ENV_REDUND; return ret; } @@ -342,10 +343,10 @@ void env_relocate_spec(void) set_default_env("!bad env area"); goto done; } else if (!read1_fail && read2_fail) { - gd->env_valid = 1; + gd->env_valid = ENV_VALID; env_import((char *)tmp_env1, 1); } else if (read1_fail && !read2_fail) { - gd->env_valid = 2; + gd->env_valid = ENV_REDUND; env_import((char *)tmp_env2, 1); } else { env_import_redund((char *)tmp_env1, (char *)tmp_env2); diff --git a/env/nvram.c b/env/nvram.c index 524f07d..d046c93 100644 --- a/env/nvram.c +++ b/env/nvram.c @@ -104,7 +104,7 @@ int env_init(void) if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) { gd->env_addr = (ulong)&env_ptr->data; #endif - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } else { gd->env_addr = (ulong)&default_environment[0]; gd->env_valid = 0; diff --git a/env/onenand.c b/env/onenand.c index cc3d670..d7ad45a 100644 --- a/env/onenand.c +++ b/env/onenand.c @@ -60,7 +60,7 @@ void env_relocate_spec(void) rc = env_import(buf, 1); if (rc) - gd->env_valid = 1; + gd->env_valid = ENV_VALID; } int saveenv(void) @@ -110,7 +110,7 @@ int env_init(void) { /* use default */ gd->env_addr = (ulong)&default_environment[0]; - gd->env_valid = 1; + gd->env_valid = ENV_VALID; return 0; } diff --git a/env/remote.c b/env/remote.c index eb977ee..e003e02 100644 --- a/env/remote.c +++ b/env/remote.c @@ -29,7 +29,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; } @@ -37,7 +37,7 @@ int env_init(void) { /* use default */ gd->env_addr = (ulong)&default_environment[0]; - gd->env_valid = 1; + gd->env_valid = ENV_VALID; return 0; } @@ -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; } @@ -26,7 +26,7 @@ int env_init(void) { /* use default */ gd->env_addr = (ulong)&default_environment[0]; - gd->env_valid = 1; + gd->env_valid = ENV_VALID; return 0; } @@ -48,7 +48,7 @@ int saveenv(void) return 1; } - if (gd->env_valid == 1) { + if (gd->env_valid == ENV_VALID) { puts("Writing to redundant UBI... "); if (ubi_volume_write(CONFIG_ENV_UBI_VOLUME_REDUND, (void *)env_new, CONFIG_ENV_SIZE)) { @@ -70,7 +70,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; return 0; } |