mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-06-09 23:36:03 +09:00
env: common: Factor out the common env_valid check
The check for gd->env_valid is used in both the 'if' and 'else' part of env_get_char(). Move it into that function instead for simplicity. Drop that code from the two leaf functions. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
0219fb61c1
commit
5fc5254084
17
env/common.c
vendored
17
env/common.c
vendored
|
@ -34,25 +34,20 @@ __weak uchar env_get_char_spec(int index)
|
||||||
|
|
||||||
static uchar env_get_char_init(int index)
|
static uchar env_get_char_init(int index)
|
||||||
{
|
{
|
||||||
/* if crc was bad, use the default environment */
|
return env_get_char_spec(index);
|
||||||
if (gd->env_valid)
|
|
||||||
return env_get_char_spec(index);
|
|
||||||
else
|
|
||||||
return default_environment[index];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uchar env_get_char_memory(int index)
|
static uchar env_get_char_memory(int index)
|
||||||
{
|
{
|
||||||
if (gd->env_valid)
|
return *(uchar *)(gd->env_addr + index);
|
||||||
return *(uchar *)(gd->env_addr + index);
|
|
||||||
else
|
|
||||||
return default_environment[index];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uchar env_get_char(int index)
|
uchar env_get_char(int index)
|
||||||
{
|
{
|
||||||
/* if relocated to RAM */
|
/* if env is not set up, or crc was bad, use the default environment */
|
||||||
if (gd->flags & GD_FLG_RELOC)
|
if (!gd->env_valid)
|
||||||
|
return default_environment[index];
|
||||||
|
else if (gd->flags & GD_FLG_RELOC) /* if relocated to RAM */
|
||||||
return env_get_char_memory(index);
|
return env_get_char_memory(index);
|
||||||
else
|
else
|
||||||
return env_get_char_init(index);
|
return env_get_char_init(index);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user