From patchwork Tue Jun 4 20:45:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 248857 X-Patchwork-Delegate: afleming@freescale.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 A60432C009E for ; Wed, 5 Jun 2013 06:46:03 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DB2184A026; Tue, 4 Jun 2013 22:45:51 +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 RszuoV-e9scf; Tue, 4 Jun 2013 22:45:51 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4D4524A028; Tue, 4 Jun 2013 22:45:47 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 48ACD4A028 for ; Tue, 4 Jun 2013 22:45:44 +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 RlVm4dA93H8K for ; Tue, 4 Jun 2013 22:45:35 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 BL_NJABL=SKIP(-1.5) (only DNSBL check requested) Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44]) by theia.denx.de (Postfix) with ESMTPS id 5CF304A026 for ; Tue, 4 Jun 2013 22:45:30 +0200 (CEST) Received: by mail-vb0-f44.google.com with SMTP id 11so567727vbf.3 for ; Tue, 04 Jun 2013 13:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=6WsKIHkppAz3kn3nCKzimAcDzueQ2ihVLvOkLytNYJQ=; b=ZDrhIe1I0rofsJtox3A61iEoR2DE0yR6SJPpJeAzQu0Vw0XjFhANWwy9j37LBl8dOD J3nh620HBKenG8uRbeLjCfXIsHGt9tcMQBbZedZ5nf1qIIhQ0cBzmVuWmW9PieTbyMb7 F62TN8ULJCYBAh5zxuQ4iSZJjMgyQsSeOMKBSmaMvJwYjsflLmSbXsPObTkVnV9riNux MYpKL85MgRZJvcq2ZdGbBsete+GspTDuQo1oT/1+x5s79picWQ+B25tVip3BWGNUwZQj Cl+XJeKrYUspCYJaUSVVwD1lLECIEhMgczilqF0NjxwvVAd9uw0kwtAwlGNQ8tuY3BIA KPiQ== MIME-Version: 1.0 X-Received: by 10.52.97.3 with SMTP id dw3mr16648569vdb.91.1370378728779; Tue, 04 Jun 2013 13:45:28 -0700 (PDT) Received: by 10.58.173.37 with HTTP; Tue, 4 Jun 2013 13:45:28 -0700 (PDT) In-Reply-To: <51AE41BF.8060206@wwwdotorg.org> References: <1370373446-14025-1-git-send-email-fabio.estevam@freescale.com> <51AE3E2F.9020408@wwwdotorg.org> <51AE41BF.8060206@wwwdotorg.org> Date: Tue, 4 Jun 2013 17:45:28 -0300 Message-ID: From: Fabio Estevam To: Stephen Warren Cc: Fabio Estevam , afleming@freescale.com, swarren@nvidia.com, u-boot@lists.denx.de Subject: Re: [U-Boot] [PATCH v2] mmc: Update "mmc->part_num" when performing a partition switch 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Hi Stephen, On Tue, Jun 4, 2013 at 4:36 PM, Stephen Warren 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(). Here is what I did so far: diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c index 7d82469..20a2792 100644 --- a/common/cmd_mmc.c +++ b/common/cmd_mmc.c @@ -243,8 +243,6 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (part != mmc->part_num) { ret = mmc_switch_part(dev, part); - if (!ret) - mmc->part_num = part; printf("switch to partions #%d, %s\n", part, (!ret) ? "OK" : "ERROR"); diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 0a2f535..e8d2ea6 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -702,14 +702,20 @@ static int mmc_change_freq(struct mmc *mmc) int mmc_switch_part(int dev_num, unsigned int part_num) { + int ret; struct mmc *mmc = find_mmc_device(dev_num); if (!mmc) return -1; - return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF, + 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) + mmc->part_num = part_num; + + return ret; } int mmc_getcd(struct mmc *mmc)