Add callback with __weak annotation to allow setup of environment partition number in runtime from a board file.
Signed-off-by: Dmitry Lifshitz <lifsh...@compulab.co.il> Signed-off-by: Igor Grinberg <grinb...@compulab.co.il> --- common/env_mmc.c | 35 ++++++++++++++++++++++++++--------- 1 files changed, 26 insertions(+), 9 deletions(-) diff --git a/common/env_mmc.c b/common/env_mmc.c index 045428c..5d4b5f4 100644 --- a/common/env_mmc.c +++ b/common/env_mmc.c @@ -62,6 +62,30 @@ int env_init(void) return 0; } + +#ifdef CONFIG_SYS_MMC_ENV_PART +__weak uint mmc_get_env_part(struct mmc *mmc) +{ + return CONFIG_SYS_MMC_ENV_PART; +} + +static int mmc_set_env_part(struct mmc *mmc) +{ + uint part = mmc_get_env_part(mmc); + + if (part != mmc->part_num) { + if (mmc_switch_part(CONFIG_SYS_MMC_ENV_DEV, part)) { + puts("MMC partition switch failed\n"); + return -1; + } + } + + return 0; +} +#else +static inline int mmc_set_env_part(struct mmc *mmc) {return 0; }; +#endif + static int init_mmc_for_env(struct mmc *mmc) { if (!mmc) { @@ -74,15 +98,8 @@ static int init_mmc_for_env(struct mmc *mmc) return -1; } -#ifdef CONFIG_SYS_MMC_ENV_PART - if (CONFIG_SYS_MMC_ENV_PART != mmc->part_num) { - if (mmc_switch_part(CONFIG_SYS_MMC_ENV_DEV, - CONFIG_SYS_MMC_ENV_PART)) { - puts("MMC partition switch failed\n"); - return -1; - } - } -#endif + if (mmc_set_env_part(mmc)) + return -1; return 0; } -- 1.7.5.4 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot