[U-Boot] [PATCH 1/2] env_mmc: remove condition on call to mmc_switch_part

Peter A. Bigot
2014-09-03T16:03:18Z

On 09/03/2014 10:46 AM, Stephen Warren wrote:
> On 09/02/2014 05:31 PM, Peter A. Bigot wrote:
>> Though it might be expected to do so, mmc_switch_part() does not change
>> the part_num field of the device on which the partition has been
>> changed. As such, checking to see whether the partition is already the
>> target partition will fail to correctly restore the original
>> configuration in cases like env_mmc which rely on this behavior to
>> avoid having to preserve the pre-switch partition number outside the
>> device structure.
>
>> diff --git a/common/env_mmc.c b/common/env_mmc.c
>
>> - if (part != mmc->part_num) {
>> - ret = mmc_switch_part(dev, part);
>> - if (ret)
>> - puts("MMC partition switch failed\n");
>> - }
>> + ret = mmc_switch_part(dev, part);
>> + if (ret)
>> + puts("MMC partition switch failed\n");
>
> I'm not sure this is correct, but it might be.
>
> I believe the if() is present to avoid any attempt to call
> mmc_switch_part() on a device that doesn't have HW partitions (in
> which case, both part and mmc->part_num should already be 0), since
> such an attempt might print an error message.

That could be true. The patch that added the feature didn't provide
that information. In my case, the device does have HW partitions.

> If you don't observe any error message printed after this change, then
> perhaps this patch is fine.

It does work in my environment, but would not retain the behavior you
describe. The existing code is still wrong, but the error is elsewhere:
I'll provide a new patch to supersede this one.

Peter