mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 16:52:14 +02:00
env: move more common code to env_import_redund
There is more common code in mmc, nand and ubi env drivers that can be shared by moving to env_import_redund. For this, a status/error value whether the buffers were loaded are passed as additional parameters to env_import_redund. Ideally, these are already returned to the env driver by the storage driver. This is the case for mmc, nand and ubi, so for this change, code deduplicated. Signed-off-by: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
This commit is contained in:
committed by
Tom Rini
parent
42a1820bbc
commit
31f044bd91
23
env/mmc.c
vendored
23
env/mmc.c
vendored
@@ -290,27 +290,8 @@ static int env_mmc_load(void)
|
||||
read1_fail = read_env(mmc, CONFIG_ENV_SIZE, offset1, tmp_env1);
|
||||
read2_fail = read_env(mmc, CONFIG_ENV_SIZE, offset2, tmp_env2);
|
||||
|
||||
if (read1_fail && read2_fail)
|
||||
puts("*** Error - No Valid Environment Area found\n");
|
||||
else if (read1_fail || read2_fail)
|
||||
puts("*** Warning - some problems detected "
|
||||
"reading environment; recovered successfully\n");
|
||||
|
||||
if (read1_fail && read2_fail) {
|
||||
errmsg = "!bad CRC";
|
||||
ret = -EIO;
|
||||
goto fini;
|
||||
} else if (!read1_fail && read2_fail) {
|
||||
gd->env_valid = ENV_VALID;
|
||||
env_import((char *)tmp_env1, 1);
|
||||
} else if (read1_fail && !read2_fail) {
|
||||
gd->env_valid = ENV_REDUND;
|
||||
env_import((char *)tmp_env2, 1);
|
||||
} else {
|
||||
env_import_redund((char *)tmp_env1, (char *)tmp_env2);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
ret = env_import_redund((char *)tmp_env1, read1_fail, (char *)tmp_env2,
|
||||
read2_fail);
|
||||
|
||||
fini:
|
||||
fini_mmc_for_env(mmc);
|
||||
|
Reference in New Issue
Block a user