diff options
author | Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com> | 2018-01-31 14:47:11 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2018-02-01 08:05:49 -0500 |
commit | 31f044bd91df58bed6bb8cfadfc187eedac1442e (patch) | |
tree | 6ec2b974d9b6c14666e9b743d5078a6f5b0ab050 /env/ubi.c | |
parent | 42a1820bbcc7dfedcf625b88a1013c11e9ef6709 (diff) |
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>
Diffstat (limited to 'env/ubi.c')
-rw-r--r-- | env/ubi.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -95,6 +95,7 @@ static int env_ubi_load(void) { ALLOC_CACHE_ALIGN_BUFFER(char, env1_buf, CONFIG_ENV_SIZE); ALLOC_CACHE_ALIGN_BUFFER(char, env2_buf, CONFIG_ENV_SIZE); + int read1_fail, read2_fail; env_t *tmp_env1, *tmp_env2; /* @@ -118,21 +119,20 @@ static int env_ubi_load(void) return -EIO; } - if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, (void *)tmp_env1, - CONFIG_ENV_SIZE)) { + read1_fail = ubi_volume_read(CONFIG_ENV_UBI_VOLUME, (void *)tmp_env1, + CONFIG_ENV_SIZE); + if (read1_fail) printf("\n** Unable to read env from %s:%s **\n", CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME); - } - if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME_REDUND, (void *)tmp_env2, - CONFIG_ENV_SIZE)) { + read2_fail = ubi_volume_read(CONFIG_ENV_UBI_VOLUME_REDUND, + (void *)tmp_env2, CONFIG_ENV_SIZE); + if (read2_fail) printf("\n** Unable to read redundant env from %s:%s **\n", CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME_REDUND); - } - env_import_redund((char *)tmp_env1, (char *)tmp_env2); - - return 0; + return env_import_redund((char *)tmp_env1, read1_fail, (char *)tmp_env2, + read2_fail); } #else /* ! CONFIG_SYS_REDUNDAND_ENVIRONMENT */ static int env_ubi_load(void) |