Skip to content

Commit

Permalink
env: mmc: add redundancy support in mmc_offset_try_partition
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
patrickdelaunay authored and trini committed Jul 26, 2020
1 parent 76b640c commit 5d4f7b4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions env/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 5d4f7b4

Please sign in to comment.