From mboxrd@z Thu Jan 1 00:00:00 1970 From: Igor Grinberg Date: Sun, 25 May 2014 10:23:46 +0300 Subject: [U-Boot] [PATCH 2/3] env_mmc: support env partition setup in runtime In-Reply-To: <1398593928-13860-3-git-send-email-lifshitz@compulab.co.il> References: <1398593928-13860-1-git-send-email-lifshitz@compulab.co.il> <1398593928-13860-3-git-send-email-lifshitz@compulab.co.il> Message-ID: <53819A82.5090108@compulab.co.il> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de ping.. On 04/27/14 13:18, Dmitry Lifshitz wrote: > Add callback with __weak annotation to allow setup of environment > partition number in runtime from a board file. > > Signed-off-by: Dmitry Lifshitz > Signed-off-by: Igor Grinberg > --- > 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; > } > -- Regards, Igor.