From patchwork Tue May 20 16:57:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 350800 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 D2EE2140081 for ; Wed, 21 May 2014 02:58:06 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 049774B6A7; Tue, 20 May 2014 18:58:04 +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 dl3MUHje6SVw; Tue, 20 May 2014 18:58:03 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A82104B690; Tue, 20 May 2014 18:58:01 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 87DA04B690 for ; Tue, 20 May 2014 18:57:56 +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 YL0ZIddG5PnY for ; Tue, 20 May 2014 18:57:53 +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 avon.wwwdotorg.org (avon.wwwdotorg.org [70.85.31.133]) by theia.denx.de (Postfix) with ESMTPS id 676D14B684 for ; Tue, 20 May 2014 18:57:49 +0200 (CEST) Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id 389E56307; Tue, 20 May 2014 10:57:47 -0600 (MDT) Received: from swarren-lx1.nvidia.com (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id 20059E4105; Tue, 20 May 2014 10:57:46 -0600 (MDT) From: Stephen Warren To: u-boot@lists.denx.de, Pantelis Antoniou Date: Tue, 20 May 2014 10:57:32 -0600 Message-Id: <1400605052-14714-1-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 1.8.1.5 X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.97.8 at avon.wwwdotorg.org X-Virus-Status: Clean Cc: Stephen Warren Subject: [U-Boot] [PATCH V2] cmd_mmc.c: check mmc_init() during mmc dev 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 From: Bryan Wu mmc dev ${devnum} will return 0 as success even if there is no card inserted. Booting script like tegra-common-post.h will call mmc dev ${devnum} to check the mmc device status, it always return 0 even if mmc_init() fails. Check mmc_init() return value let mmc dev command return failure when mmc_init() fails. Signed-off-by: Bryan Wu [swarren: Always return 1 on error; hush doesn't appear to support arbitrary return values. Fixed compilation error due to multiple declaration of ret variable.] Tested-by: Stephen Warren Signed-off-by: Stephen Warren --- v2: * Always return 1 on error; hush doesn't appear to support arbitrary return values. * Fixed compilation error due to multiple declaration of ret variable. --- common/cmd_mmc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c index 572aa895fa1c..2e564572f74d 100644 --- a/common/cmd_mmc.c +++ b/common/cmd_mmc.c @@ -217,7 +217,10 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; } - mmc_init(mmc); + ret = mmc_init(mmc); + if (ret) + return 1; + if (part != -1) { ret = mmc_select_hwpart(dev, part); printf("switch to partitions #%d, %s\n",