[meta-ti] [ti-uboot][PATCH] mmc: restore capacity when switching to partition 0

Tom Rini trini at ti.com
Tue Sep 2 09:44:51 PDT 2014


On Mon, Sep 01, 2014 at 10:11:30PM -0500, Peter A. Bigot wrote:

> The capacity and lba for an MMC device with part_num 0 reflects the
> whole device.  When mmc_switch_part() successfully switches to a
> partition, the capacity is changed to that partition.  As partition 0
> does not physically exist, attempts to switch back to the whole device
> will indicate an error, but should still restore the capacity setting.

In other words:
# mmc dev 0:1
...
# mmc dev 0:0

Fails?  And the following patch fixes it.

> 
> Signed-off-by: Peter A. Bigot <pab at pabigot.com>
> ---
>  drivers/mmc/mmc.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index b5477b1..b05c6ee 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -596,10 +596,11 @@ int mmc_switch_part(int dev_num, unsigned int part_num)
>  	ret = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF,
>  			 (mmc->part_config & ~PART_ACCESS_MASK)
>  			 | (part_num & PART_ACCESS_MASK));
> -	if (ret)
> -		return ret;
>  
> -	return mmc_set_capacity(mmc, part_num);
> +	if ((0 == ret) || ((-ENODEV == ret) && (0 == part_num)))

This is backwards from how we usually code things:

if ((ret == 0) || ((ret == -ENODEV) && (part_num == 0)))

And should have a comment above it that's a short summary of the commit
message so this doesn't get lost later on.

> +		ret = mmc_set_capacity(mmc, part_num);
> +
> +	return ret;
>  }
>  
>  int mmc_getcd(struct mmc *mmc)
> -- 
> 1.8.5.5
> 
> -- 
> _______________________________________________
> meta-ti mailing list
> meta-ti at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/meta-ti

And speaking of getting lost, this isn't the U-Boot mailing list so the
change would get lost with the next release.  Please make sure to post
the next version to the u-boot ML as well and CC Pantelis.   Thanks!

-- 
Tom


More information about the meta-ti mailing list