X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fenv_dataflash.c;h=8a944324f22c86c28676f04489e5b143d97235a6;hb=19cf2ec90d8ce52da60c1693693c4048cb810967;hp=8834da032bdd82f5b78acf51d772e9972057a1a4;hpb=31466294b0c4ff372288229b0997de51f8ecaf3f;p=u-boot diff --git a/common/env_dataflash.c b/common/env_dataflash.c index 8834da032b..8a944324f2 100644 --- a/common/env_dataflash.c +++ b/common/env_dataflash.c @@ -26,6 +26,8 @@ #include #include +DECLARE_GLOBAL_DATA_PTR; + env_t *env_ptr = NULL; char * env_name_spec = "dataflash"; @@ -42,22 +44,22 @@ extern uchar default_environment[]; uchar env_get_char_spec (int index) { uchar c; - read_dataflash (CFG_ENV_ADDR+index+offsetof(env_t,data),1,&c); + read_dataflash(CFG_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(CFG_ENV_ADDR, CFG_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; + /* env must be copied to do not alter env structure in memory*/ + unsigned char temp[CFG_ENV_SIZE]; memcpy(temp, env_ptr, CFG_ENV_SIZE); - return write_dataflash (CFG_ENV_ADDR, (unsigned long)temp, CFG_ENV_SIZE); + return write_dataflash(CFG_ENV_ADDR, (unsigned long)temp, CFG_ENV_SIZE); } /************************************************************************ @@ -68,8 +70,6 @@ int i; */ int env_init(void) { - DECLARE_GLOBAL_DATA_PTR; - ulong crc, len, new; unsigned off; uchar buf[64]; @@ -77,13 +77,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(CFG_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(CFG_ENV_ADDR + off, n, (char *)buf); new = crc32 (new, buf, n); len -= n; off += n;