From patchwork Tue Oct 8 13:47: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: 3003831 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4006EBF924 for ; Tue, 8 Oct 2013 13:52:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 13C162018C for ; Tue, 8 Oct 2013 13:52:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AEE932017C for ; Tue, 8 Oct 2013 13:52:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754714Ab3JHNwP (ORCPT ); Tue, 8 Oct 2013 09:52:15 -0400 Received: from [213.199.154.209] ([213.199.154.209]:33287 "EHLO am1outboundpool.messaging.microsoft.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754348Ab3JHNwN (ORCPT ); Tue, 8 Oct 2013 09:52:13 -0400 Received: from mail20-am1-R.bigfish.com (10.3.201.237) by AM1EHSOBE026.bigfish.com (10.3.207.148) with Microsoft SMTP Server id 14.1.225.22; Tue, 8 Oct 2013 13:51:37 +0000 Received: from mail20-am1 (localhost [127.0.0.1]) by mail20-am1-R.bigfish.com (Postfix) with ESMTP id 001FF200094; Tue, 8 Oct 2013 13:51:36 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6hzz1de098h1de097h8275bhz2dh2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h1155h) Received: from mail20-am1 (localhost.localdomain [127.0.0.1]) by mail20-am1 (MessageSwitch) id 1381240295287368_29412; Tue, 8 Oct 2013 13:51:35 +0000 (UTC) Received: from AM1EHSMHS001.bigfish.com (unknown [10.3.201.238]) by mail20-am1.bigfish.com (Postfix) with ESMTP id 405CA60087; Tue, 8 Oct 2013 13:51:35 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by AM1EHSMHS001.bigfish.com (10.3.207.101) with Microsoft SMTP Server (TLS) id 14.16.227.3; Tue, 8 Oct 2013 13:51:33 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.3.158.2; Tue, 8 Oct 2013 13:51:32 +0000 Received: from fabio-OptiPlex-7010.am.freescale.net ([10.29.244.68]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id r98DpTnA009819; Tue, 8 Oct 2013 06:51:30 -0700 From: Fabio Estevam To: CC: , , , , Fabio Estevam Subject: [PATCH] mmc: sdhci-esdhc-imx: Check the return value from clk_prepare_enable() Date: Tue, 8 Oct 2013 10:47:28 -0300 Message-ID: <1381240048-22685-1-git-send-email-fabio.estevam@freescale.com> X-Mailer: git-send-email 1.8.1.2 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP clk_prepare_enable() may fail, so let's check its return value and propagate it in the case of error. Also, fix the sequence for disabling the clock in the probe error path and also in the remove function. Signed-off-by: Fabio Estevam --- drivers/mmc/host/sdhci-esdhc-imx.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index b9899e9..abc9836 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -877,9 +877,17 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) pltfm_host->clk = imx_data->clk_per; - clk_prepare_enable(imx_data->clk_per); - clk_prepare_enable(imx_data->clk_ipg); - clk_prepare_enable(imx_data->clk_ahb); + err = clk_prepare_enable(imx_data->clk_per); + if (err) + goto free_sdhci; + + err = clk_prepare_enable(imx_data->clk_ipg); + if (err) + goto err_ipg; + + err = clk_prepare_enable(imx_data->clk_ahb); + if (err) + goto err_ahb; imx_data->pinctrl = devm_pinctrl_get(&pdev->dev); if (IS_ERR(imx_data->pinctrl)) { @@ -995,9 +1003,11 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) return 0; disable_clk: - clk_disable_unprepare(imx_data->clk_per); - clk_disable_unprepare(imx_data->clk_ipg); clk_disable_unprepare(imx_data->clk_ahb); +err_ahb: + clk_disable_unprepare(imx_data->clk_ipg); +err_ipg: + clk_disable_unprepare(imx_data->clk_per); free_sdhci: sdhci_pltfm_free(pdev); return err; @@ -1012,9 +1022,9 @@ static int sdhci_esdhc_imx_remove(struct platform_device *pdev) sdhci_remove_host(host, dead); - clk_disable_unprepare(imx_data->clk_per); - clk_disable_unprepare(imx_data->clk_ipg); clk_disable_unprepare(imx_data->clk_ahb); + clk_disable_unprepare(imx_data->clk_ipg); + clk_disable_unprepare(imx_data->clk_per); sdhci_pltfm_free(pdev);