summaryrefslogtreecommitdiff
path: root/env/ubi.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-08-03 12:22:17 -0600
committerTom Rini <trini@konsulko.com>2017-08-16 08:31:24 -0400
commitc5951991942330c129f3b181e94969d7c01e9abb (patch)
tree39b5ee4ee37e5a595e088456e792d7251f7ee1ca /env/ubi.c
parent21f639446d6bccb6cc550140d36bd3ebd74fcee8 (diff)
env: Adjust the load() method to return an error
The load() methods have inconsistent behaviour on error. Some of them load an empty default environment. Some load an environment containing an error message. Others do nothing. As a step in the right direction, have the method return an error code. Then the caller could handle this itself in a consistent way. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'env/ubi.c')
-rw-r--r--env/ubi.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/env/ubi.c b/env/ubi.c
index 9399f943dc..1c4653d4f6 100644
--- a/env/ubi.c
+++ b/env/ubi.c
@@ -91,7 +91,7 @@ static int env_ubi_save(void)
#endif /* CONFIG_CMD_SAVEENV */
#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
-static void env_ubi_load(void)
+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);
@@ -115,7 +115,7 @@ static void env_ubi_load(void)
printf("\n** Cannot find mtd partition \"%s\"\n",
CONFIG_ENV_UBI_PART);
set_default_env(NULL);
- return;
+ return -EIO;
}
if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, (void *)tmp_env1,
@@ -131,9 +131,11 @@ static void env_ubi_load(void)
}
env_import_redund((char *)tmp_env1, (char *)tmp_env2);
+
+ return 0;
}
#else /* ! CONFIG_SYS_REDUNDAND_ENVIRONMENT */
-static void env_ubi_load(void)
+static int env_ubi_load(void)
{
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
@@ -151,17 +153,19 @@ static void env_ubi_load(void)
printf("\n** Cannot find mtd partition \"%s\"\n",
CONFIG_ENV_UBI_PART);
set_default_env(NULL);
- return;
+ return -EIO;
}
if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, buf, CONFIG_ENV_SIZE)) {
printf("\n** Unable to read env from %s:%s **\n",
CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME);
set_default_env(NULL);
- return;
+ return -EIO;
}
env_import(buf, 1);
+
+ return 0;
}
#endif /* CONFIG_SYS_REDUNDAND_ENVIRONMENT */