X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fenv_dataflash.c;h=27a3bbcca03fba009cdcc3357ab0940e7af43b72;hb=2fefa2ae868d3508ff432ba73a0db53356035c71;hp=93fff29b05a4a6dda262fddbee115467495eae0a;hpb=b86d7622b33892b1dafe761a7a9eaeeab9f3816b;p=oweals%2Fu-boot.git diff --git a/common/env_dataflash.c b/common/env_dataflash.c index 93fff29b05..27a3bbcca0 100644 --- a/common/env_dataflash.c +++ b/common/env_dataflash.c @@ -18,9 +18,6 @@ * */ #include - -#if defined(CFG_ENV_IS_IN_DATAFLASH) /* Environment is in DataFlash */ - #include #include #include @@ -38,28 +35,27 @@ extern int write_dataflash (unsigned long addr_dest, unsigned long addr_src, unsigned long size); extern int AT91F_DataflashInit (void); extern uchar default_environment[]; -/* extern int default_environment_size; */ uchar env_get_char_spec (int index) { uchar c; - read_dataflash (CFG_ENV_ADDR+index+offsetof(env_t,data),1,&c); + read_dataflash(CONFIG_ENV_ADDR + index + offsetof(env_t,data), + 1, (char *)&c); return (c); } void env_relocate_spec (void) { - read_dataflash (CFG_ENV_ADDR,CFG_ENV_SIZE,(uchar *)env_ptr); + read_dataflash(CONFIG_ENV_ADDR, CONFIG_ENV_SIZE, (char *)env_ptr); } int saveenv(void) { -/* env must be copied to do not alter env structure in memory*/ -unsigned char temp[CFG_ENV_SIZE]; -int i; - memcpy(temp, env_ptr, CFG_ENV_SIZE); - return write_dataflash (CFG_ENV_ADDR, (unsigned long)temp, CFG_ENV_SIZE); + /* env must be copied to do not alter env structure in memory*/ + unsigned char temp[CONFIG_ENV_SIZE]; + memcpy(temp, env_ptr, CONFIG_ENV_SIZE); + return write_dataflash(CONFIG_ENV_ADDR, (unsigned long)temp, CONFIG_ENV_SIZE); } /************************************************************************ @@ -77,13 +73,14 @@ int env_init(void) AT91F_DataflashInit(); /* prepare for DATAFLASH read/write */ /* read old CRC */ - read_dataflash (CFG_ENV_ADDR+offsetof(env_t,crc),sizeof(ulong),&crc); + read_dataflash(CONFIG_ENV_ADDR + offsetof(env_t, crc), + sizeof(ulong), (char *)&crc); new = 0; len = ENV_SIZE; off = offsetof(env_t,data); while (len > 0) { int n = (len > sizeof(buf)) ? sizeof(buf) : len; - read_dataflash (CFG_ENV_ADDR+off,n , buf); + read_dataflash(CONFIG_ENV_ADDR + off, n, (char *)buf); new = crc32 (new, buf, n); len -= n; off += n; @@ -97,7 +94,5 @@ int env_init(void) } } - return (0); + return (0); } - -#endif /* CFG_ENV_IS_IN_DATAFLASH */