summaryrefslogtreecommitdiff
path: root/env
diff options
context:
space:
mode:
authorPatrick Delaunay <patrick.delaunay@st.com>2020-06-15 10:38:57 +0200
committerTom Rini <trini@konsulko.com>2020-07-26 14:35:30 -0400
commit5d4f7b4e2a1a2df459172ec95cbcdd6373dd707a (patch)
treeab11a71616bc9d5534d4b633520819c1b9be8b9c /env
parent76b640c3f2c7299acc5f1e89f8788862667cc5a0 (diff)
env: mmc: add redundancy support in mmc_offset_try_partition
Manage 2 copy at the end of the partition selected by config "u-boot,mmc-env-partition" to save the U-Boot environment, with CONFIG_ENV_SIZE and 2*CONFIG_ENV_SIZE offset. This patch allows to support redundancy (CONFIG_ENV_OFFSET_REDUND). Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Diffstat (limited to 'env')
-rw-r--r--env/mmc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/env/mmc.c b/env/mmc.c
index 5de4a45817..aca61b75e9 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -34,7 +34,7 @@ __weak int mmc_get_env_dev(void)
}
#if CONFIG_IS_ENABLED(OF_CONTROL)
-static inline int mmc_offset_try_partition(const char *str, s64 *val)
+static inline int mmc_offset_try_partition(const char *str, int copy, s64 *val)
{
struct disk_partition info;
struct blk_desc *desc;
@@ -59,7 +59,7 @@ static inline int mmc_offset_try_partition(const char *str, s64 *val)
len = DIV_ROUND_UP(CONFIG_ENV_SIZE, info.blksz);
/* use the top of the partion for the environment */
- *val = (info.start + info.size - len) * info.blksz;
+ *val = (info.start + info.size - (1 + copy) * len) * info.blksz;
return 0;
}
@@ -84,7 +84,7 @@ static inline s64 mmc_offset(int copy)
str = fdtdec_get_config_string(gd->fdt_blob, dt_prop.partition);
if (str) {
/* try to place the environment at end of the partition */
- err = mmc_offset_try_partition(str, &val);
+ err = mmc_offset_try_partition(str, copy, &val);
if (!err)
return val;
}