aboutsummaryrefslogtreecommitdiff
path: root/env/common.c
diff options
context:
space:
mode:
authorMarek Vasut2020-07-07 20:51:35 +0200
committerTom Rini2020-07-31 10:13:00 -0400
commit890feecaab72a630eac3344443e053173f4ad02f (patch)
treec36661a5b3a0d8e65f813cc1f5fcf06d3f100d2c /env/common.c
parentef9bef2bfed36424a3a6678d76d9eb7b710de1ac (diff)
env: Discern environment coming from external storage
Add another custom environment flag which discerns environment coming from external storage from environment set by U-Boot itself. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'env/common.c')
-rw-r--r--env/common.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/env/common.c b/env/common.c
index 0db56e610a2..ed18378000f 100644
--- a/env/common.c
+++ b/env/common.c
@@ -110,7 +110,7 @@ int env_set_default_vars(int nvars, char * const vars[], int flags)
* Check if CRC is valid and (if yes) import the environment.
* Note that "buf" may or may not be aligned.
*/
-int env_import(const char *buf, int check)
+int env_import(const char *buf, int check, int flags)
{
env_t *ep = (env_t *)buf;
@@ -125,7 +125,7 @@ int env_import(const char *buf, int check)
}
}
- if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0, 0,
+ if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', flags, 0,
0, NULL)) {
gd->flags |= GD_FLG_ENV_READY;
return 0;
@@ -142,7 +142,8 @@ int env_import(const char *buf, int check)
static unsigned char env_flags;
int env_import_redund(const char *buf1, int buf1_read_fail,
- const char *buf2, int buf2_read_fail)
+ const char *buf2, int buf2_read_fail,
+ int flags)
{
int crc1_ok, crc2_ok;
env_t *ep, *tmp_env1, *tmp_env2;
@@ -162,10 +163,10 @@ int env_import_redund(const char *buf1, int buf1_read_fail,
return -EIO;
} else if (!buf1_read_fail && buf2_read_fail) {
gd->env_valid = ENV_VALID;
- return env_import((char *)tmp_env1, 1);
+ return env_import((char *)tmp_env1, 1, flags);
} else if (buf1_read_fail && !buf2_read_fail) {
gd->env_valid = ENV_REDUND;
- return env_import((char *)tmp_env2, 1);
+ return env_import((char *)tmp_env2, 1, flags);
}
crc1_ok = crc32(0, tmp_env1->data, ENV_SIZE) ==
@@ -200,7 +201,7 @@ int env_import_redund(const char *buf1, int buf1_read_fail,
ep = tmp_env2;
env_flags = ep->flags;
- return env_import((char *)ep, 0);
+ return env_import((char *)ep, 0, flags);
}
#endif /* CONFIG_SYS_REDUNDAND_ENVIRONMENT */