mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-31 19:41:46 +00:00
env: clean env_eeprom.c checkpatch and code style
Cleanup the env_eeprom.c checkpatch warnings, errors and coding style. Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
This commit is contained in:
parent
bd2a23ac61
commit
dd2a233c94
1 changed files with 46 additions and 58 deletions
|
@ -37,7 +37,7 @@
|
|||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
env_t *env_ptr = NULL;
|
||||
env_t *env_ptr;
|
||||
|
||||
char *env_name_spec = "EEPROM";
|
||||
int env_eeprom_bus = -1;
|
||||
|
@ -97,18 +97,16 @@ static int eeprom_bus_write(unsigned dev_addr, unsigned offset,
|
|||
uchar env_get_char_spec(int index)
|
||||
{
|
||||
uchar c;
|
||||
unsigned int off;
|
||||
off = CONFIG_ENV_OFFSET;
|
||||
unsigned int off = CONFIG_ENV_OFFSET;
|
||||
|
||||
#ifdef CONFIG_ENV_OFFSET_REDUND
|
||||
if (gd->env_valid == 2)
|
||||
off = CONFIG_ENV_OFFSET_REDUND;
|
||||
#endif
|
||||
eeprom_bus_read(CONFIG_SYS_DEF_EEPROM_ADDR,
|
||||
off + index + offsetof(env_t,data),
|
||||
&c, 1);
|
||||
off + index + offsetof(env_t, data), &c, 1);
|
||||
|
||||
return (c);
|
||||
return c;
|
||||
}
|
||||
|
||||
void env_relocate_spec(void)
|
||||
|
@ -121,9 +119,7 @@ void env_relocate_spec (void)
|
|||
off = CONFIG_ENV_OFFSET_REDUND;
|
||||
#endif
|
||||
eeprom_bus_read(CONFIG_SYS_DEF_EEPROM_ADDR,
|
||||
off,
|
||||
(uchar *)buf,
|
||||
CONFIG_ENV_SIZE);
|
||||
off, (uchar *)buf, CONFIG_ENV_SIZE);
|
||||
|
||||
env_import(buf, 1);
|
||||
}
|
||||
|
@ -160,24 +156,20 @@ int saveenv(void)
|
|||
#endif
|
||||
|
||||
rc = eeprom_bus_write(CONFIG_SYS_DEF_EEPROM_ADDR,
|
||||
off,
|
||||
(uchar *)&env_new,
|
||||
CONFIG_ENV_SIZE);
|
||||
off, (uchar *)&env_new, CONFIG_ENV_SIZE);
|
||||
|
||||
#ifdef CONFIG_ENV_OFFSET_REDUND
|
||||
if (rc == 0) {
|
||||
eeprom_bus_write(CONFIG_SYS_DEF_EEPROM_ADDR,
|
||||
off_red + offsetof(env_t, flags),
|
||||
(uchar *)&flag_obsolete,
|
||||
1);
|
||||
(uchar *)&flag_obsolete, 1);
|
||||
|
||||
if (gd->env_valid == 1)
|
||||
gd->env_valid = 2;
|
||||
else
|
||||
gd->env_valid = 1;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -187,17 +179,13 @@ int saveenv(void)
|
|||
* We are still running from ROM, so data use is limited.
|
||||
* Use a (moderately small) buffer on the stack
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ENV_OFFSET_REDUND
|
||||
int env_init(void)
|
||||
{
|
||||
ulong len;
|
||||
ulong crc[2], crc_tmp;
|
||||
ulong len, crc[2], crc_tmp;
|
||||
unsigned int off, off_env[2];
|
||||
uchar buf[64];
|
||||
int crc_ok[2] = {0,0};
|
||||
unsigned char flags[2];
|
||||
int i;
|
||||
uchar buf[64], flags[2];
|
||||
int i, crc_ok[2] = {0, 0};
|
||||
|
||||
eeprom_init(); /* prepare for EEPROM read/write */
|
||||
|
||||
|
@ -227,6 +215,7 @@ int env_init(void)
|
|||
len -= n;
|
||||
off += n;
|
||||
}
|
||||
|
||||
if (crc_tmp == crc[i])
|
||||
crc_ok[i] = 1;
|
||||
}
|
||||
|
@ -238,8 +227,7 @@ int env_init(void)
|
|||
return 0;
|
||||
} else if (crc_ok[0] && !crc_ok[1]) {
|
||||
gd->env_valid = 1;
|
||||
}
|
||||
else if (!crc_ok[0] && crc_ok[1]) {
|
||||
} else if (!crc_ok[0] && crc_ok[1]) {
|
||||
gd->env_valid = 2;
|
||||
} else {
|
||||
/* both ok - check serial */
|
||||
|
@ -260,7 +248,7 @@ int env_init(void)
|
|||
else if (gd->env_valid == 1)
|
||||
gd->env_addr = off_env[0] + offsetof(env_t, data);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int env_init(void)
|
||||
|
@ -298,6 +286,6 @@ int env_init(void)
|
|||
gd->env_valid = 0;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue