X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=common%2Fenv_dataflash.c;h=fed919e675ec6b3eb3c4d8ea6aa7d031e3f8db0c;hb=0e8d158664a913392cb01fb11a948d83f72e105e;hp=8bfbbc943e138c968a6d79110690a605f18c2cbb;hpb=5779d8d985d95104ad74332f5fa3cb6c67645509;p=platform%2Fkernel%2Fu-boot.git diff --git a/common/env_dataflash.c b/common/env_dataflash.c index 8bfbbc9..fed919e 100644 --- a/common/env_dataflash.c +++ b/common/env_dataflash.c @@ -18,15 +18,13 @@ * */ #include - -#if defined(CFG_ENV_IS_IN_DATAFLASH) /* Environment is in DataFlash */ - #include #include #include -#include #include +DECLARE_GLOBAL_DATA_PTR; + env_t *env_ptr = NULL; char * env_name_spec = "dataflash"; @@ -43,22 +41,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(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); } /************************************************************************ @@ -69,8 +67,6 @@ int i; */ int env_init(void) { - DECLARE_GLOBAL_DATA_PTR; - ulong crc, len, new; unsigned off; uchar buf[64]; @@ -78,13 +74,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; @@ -98,7 +95,5 @@ int env_init(void) } } - return (0); + return (0); } - -#endif /* CFG_ENV_IS_IN_DATAFLASH */