From patchwork Thu Jan 17 15:15:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 1996961 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 104B9DF2E1 for ; Thu, 17 Jan 2013 15:19:32 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TvrBp-0000w8-A4; Thu, 17 Jan 2013 15:15:37 +0000 Received: from smtp.citrix.com ([66.165.176.89]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TvrBl-0000vh-RW for linux-arm-kernel@lists.infradead.org; Thu, 17 Jan 2013 15:15:34 +0000 X-IronPort-AV: E=Sophos;i="4.84,486,1355097600"; d="scan'208";a="4092475" Received: from ftlpex01cl01.citrite.net ([10.13.107.78]) by FTLPIPO01.CITRIX.COM with ESMTP/TLS/AES128-SHA; 17 Jan 2013 15:15:30 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.2.318.1; Thu, 17 Jan 2013 10:15:30 -0500 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1TvrBi-0003I0-0X; Thu, 17 Jan 2013 15:15:30 +0000 Date: Thu, 17 Jan 2013 15:15:25 +0000 From: Stefano Stabellini X-X-Sender: sstabellini@kaball.uk.xensource.com To: Subject: [PATCH] mmc_select_voltage only if host->ocr_avail_mmc Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130117_101534_114862_C5113988 X-CRM114-Status: GOOD ( 11.18 ) X-Spam-Score: -7.6 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [66.165.176.89 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Stefano Stabellini , linux-kernel@vger.kernel.org, Ian Campbell , Pierre Ossman , cjb@laptop.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On my platform (ARM Versatile Express Cortex A15 emulator) host->ocr_avail_mmc is 0. mmc_attach_mmc knows that it could be 0, in fact at the beginning of the function it checks if host->ocr_avail_mmc is not 0 before setting host->ocr_avail. However later on, is going to call mmc_select_voltage regardeless of its value. If host->ocr_avail_mmc is 0, host->ocr ends up being 0 too, and we error out. I admit that I am not terribly familiar with this code, but it seems to me that we should only call mmc_select_voltage and check the return value if host->ocr_avail_mmc. If that is not the right fix please advise. --- mmc_attach_mmc: only call mmc_select_voltage if host->ocr_avail_mmc host->ocr_avail_mmc can be 0, in fact mmc_attach_mmc checks if host->ocr_avail_mmc is not 0 before setting host->ocr_avail. However later on, is going to call mmc_select_voltage regardeless of its value. If host->ocr_avail_mmc is 0, host->ocr ends up being 0 too, and mmc_select_voltage errors out. This patch fixes that by only calling mmc_select_voltage iff host->ocr_avail_mmc != 0. Signed-off-by: Stefano Stabellini diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index e6e3911..0edd33b 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1529,14 +1529,15 @@ int mmc_attach_mmc(struct mmc_host *host) ocr &= ~0x7F; } - host->ocr = mmc_select_voltage(host, ocr); - - /* - * Can we support the voltage of the card? - */ - if (!host->ocr) { - err = -EINVAL; - goto err; + if (host->ocr_avail_mmc) { + host->ocr = mmc_select_voltage(host, ocr); + /* + * Can we support the voltage of the card? + */ + if (!host->ocr) { + err = -EINVAL; + goto err; + } } /*