
On 06/04/2013 02:45 PM, Fabio Estevam wrote:
Hi Stephen,
On Tue, Jun 4, 2013 at 4:36 PM, Stephen Warren swarren@wwwdotorg.org wrote:
That seems like a reasonable way for the code to work. However, you'd need to modify common/env_mmc.c:init_mmc_for_env() so that it saves off mmc->part_num before switching MMC partitions, so that fini_mmc_for_env() knows which partition to switch back to. Right now, it relies on the fact that mmc_switch_part() does not update mmc->part_num, and hence uses that value to save the previously selected partition ID.
Also, if you make this change, I think you can update common/cmd_mmc.c:do_mmcops(), since it will no longer need to update mmc->part_num after a successful switch.
I understood your second suggestion and did the changes below, but I am not sure on the first one regarding the change you proposed inside init_mmc_for_env().
In env_mmc.c, you'll want something like:
+#ifdef CONFIG_SYS_MMC_ENV_PART +static char orig_part_num; +#ifdef CONFIG_SYS_MMC_ENV_PART
static int init_mmc_for_env(struct mmc *mmc) ... #ifdef CONFIG_SYS_MMC_ENV_PART + orig_part_num = mmc->part_num; 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 ... static void fini_mmc_for_env(struct mmc *mmc) { #ifdef CONFIG_SYS_MMC_ENV_PART - if (CONFIG_SYS_MMC_ENV_PART != mmc->part_num) + if (mmc->part_num != orig_part_num) mmc_switch_part(CONFIG_SYS_MMC_ENV_DEV, - mmc->part_num); + orig_part_num); #endif }