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>
diff --git a/env/mmc.c b/env/mmc.c
index 88ffc91..3f3092d 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -207,7 +207,7 @@
 }
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-static void env_mmc_load(void)
+static int env_mmc_load(void)
 {
 #if !defined(ENV_IS_EMBEDDED)
 	struct mmc *mmc;
@@ -224,13 +224,13 @@
 
 	errmsg = init_mmc_for_env(mmc);
 	if (errmsg) {
-		ret = 1;
+		ret = -EIO;
 		goto err;
 	}
 
 	if (mmc_get_env_addr(mmc, 0, &offset1) ||
 	    mmc_get_env_addr(mmc, 1, &offset2)) {
-		ret = 1;
+		ret = -EIO;
 		goto fini;
 	}
 
@@ -245,7 +245,7 @@
 
 	if (read1_fail && read2_fail) {
 		errmsg = "!bad CRC";
-		ret = 1;
+		ret = -EIO;
 		goto fini;
 	} else if (!read1_fail && read2_fail) {
 		gd->env_valid = ENV_VALID;
@@ -264,10 +264,12 @@
 err:
 	if (ret)
 		set_default_env(errmsg);
+
 #endif
+	return ret;
 }
 #else /* ! CONFIG_ENV_OFFSET_REDUND */
-static void env_mmc_load(void)
+static int env_mmc_load(void)
 {
 #if !defined(ENV_IS_EMBEDDED)
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
@@ -281,18 +283,18 @@
 
 	errmsg = init_mmc_for_env(mmc);
 	if (errmsg) {
-		ret = 1;
+		ret = -EIO;
 		goto err;
 	}
 
 	if (mmc_get_env_addr(mmc, 0, &offset)) {
-		ret = 1;
+		ret = -EIO;
 		goto fini;
 	}
 
 	if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) {
 		errmsg = "!read failed";
-		ret = 1;
+		ret = -EIO;
 		goto fini;
 	}
 
@@ -305,6 +307,7 @@
 	if (ret)
 		set_default_env(errmsg);
 #endif
+	return ret;
 }
 #endif /* CONFIG_ENV_OFFSET_REDUND */