From patchwork Tue Sep 2 23:31:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Bigot X-Patchwork-Id: 385354 X-Patchwork-Delegate: panto@antoniou-consulting.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id E5EE414017D for ; Wed, 3 Sep 2014 09:39:46 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7177FA7600; Wed, 3 Sep 2014 01:39:38 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YtM7ZgXq+lrT; Wed, 3 Sep 2014 01:39:38 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 20D64A74C0; Wed, 3 Sep 2014 01:39:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 49E774B6B1 for ; Wed, 3 Sep 2014 01:39:26 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id h6J4EbvIS2Ds for ; Wed, 3 Sep 2014 01:39:24 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from p3plsmtpa06-01.prod.phx3.secureserver.net (p3plsmtpa06-01.prod.phx3.secureserver.net [173.201.192.102]) by theia.denx.de (Postfix) with ESMTP id 8D1314B6B2 for ; Wed, 3 Sep 2014 01:39:23 +0200 (CEST) Received: from llc.pab ([66.41.60.82]) by p3plsmtpa06-01.prod.phx3.secureserver.net with id mPXl1o0071mTNtu01PXsaz; Tue, 02 Sep 2014 16:31:52 -0700 From: "Peter A. Bigot" To: u-boot@lists.denx.de Date: Tue, 2 Sep 2014 18:31:23 -0500 Message-Id: <1409700683-25393-3-git-send-email-pab@pabigot.com> X-Mailer: git-send-email 1.8.5.5 In-Reply-To: <1409700683-25393-1-git-send-email-pab@pabigot.com> References: <1409700683-25393-1-git-send-email-pab@pabigot.com> Cc: trini@ti.com, panto@antoniou-consulting.com Subject: [U-Boot] [PATCH 2/2] mmc: restore capacity when switching to partition 0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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. Signed-off-by: Peter A. Bigot Tested-by: Tom Rini Tested-by: Pantelis Antoniou Acked-by: Pantelis Antoniou --- drivers/mmc/mmc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index a26f3ce..fa04a3f 100644 --- 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; } int mmc_getcd(struct mmc *mmc)