From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Wed, 03 Sep 2014 09:48:06 -0600 Subject: [U-Boot] [PATCH 2/2] mmc: restore capacity when switching to partition 0 In-Reply-To: <1409700683-25393-3-git-send-email-pab@pabigot.com> References: <1409700683-25393-1-git-send-email-pab@pabigot.com> <1409700683-25393-3-git-send-email-pab@pabigot.com> Message-ID: <54073836.6090809@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 09/02/2014 05:31 PM, 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 the capacity setting for the whole device > must still be restored to match the partition. > diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c > @@ -594,10 +594,15 @@ 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); > + /* > + * Set the capacity if the switch succeeded or was intended > + * to return to representing the raw device. > + */ > + if ((ret == 0) || ((ret == -ENODEV) && (part_num == 0))) > + ret = mmc_set_capacity(mmc, part_num); > + > + return ret; > } I think this wouldn't be needed without patch 1/2, since without that patch, no partition switching should ever happen if HW partitions don't exist, and hence this patch shouldn't be required.