From c5951991942330c129f3b181e94969d7c01e9abb Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 3 Aug 2017 12:22:17 -0600 Subject: 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 --- env/sata.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'env/sata.c') diff --git a/env/sata.c b/env/sata.c index 16d8f939db..a77029774e 100644 --- a/env/sata.c +++ b/env/sata.c @@ -98,21 +98,24 @@ static void env_sata_load(void) int env_sata; if (sata_initialize()) - return; + return -EIO; env_sata = sata_get_env_dev(); sata = sata_get_dev(env_sata); if (sata == NULL) { - printf("Unknown SATA(%d) device for environment!\n", - env_sata); - return; + printf("Unknown SATA(%d) device for environment!\n", env_sata); + return -EIO; } - if (read_env(sata, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf)) - return set_default_env(NULL); + if (read_env(sata, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf)) { + set_default_env(NULL); + return -EIO; + } env_import(buf, 1); + + return 0; } U_BOOT_ENV_LOCATION(sata) = { -- cgit v1.2.3