From patchwork Wed Oct 9 20:37:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 3011451 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 460779F245 for ; Wed, 9 Oct 2013 20:37:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E93E720158 for ; Wed, 9 Oct 2013 20:37:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD6F520126 for ; Wed, 9 Oct 2013 20:37:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754076Ab3JIUhu (ORCPT ); Wed, 9 Oct 2013 16:37:50 -0400 Received: from mail-vc0-f182.google.com ([209.85.220.182]:58880 "EHLO mail-vc0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753965Ab3JIUht (ORCPT ); Wed, 9 Oct 2013 16:37:49 -0400 Received: by mail-vc0-f182.google.com with SMTP id im17so942492vcb.41 for ; Wed, 09 Oct 2013 13:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=PgkIJnWeP15bAzYIZiJXEzesc88Qd4Ukii7Tl8nGlEA=; b=Ss0F27xU3BtmLIlWu+Gs9dYDf87uKKc+JEzVntzB4wEVbj+lRykBTYHwfXWqZAqhz2 TDLy5FmCGXRXWVZWPGZyDRSZJA8IMICdla5SAslIRr5tispoON+P6L2MCLWQCUQiR7WM EzaUL1UlUgDXiZBEbNLJbTbv40dKAApaEhaRhog3pDaL33DFMqbgs6vHqPO7yBYwTyZ2 7aZqG3OA2NDTYrTMh68w/1COzwphdKMS71oe5aoiixi++joee1WAwP0/5pT4wh0oIUCr VdXc6+cjDBr0Oss9IHfi2kdheMy0zI98E+iWYMbTvZBw/5f4veKvHpUxZl2PXBu9ruBk FcZQ== X-Received: by 10.220.183.2 with SMTP id ce2mr909824vcb.58.1381351068673; Wed, 09 Oct 2013 13:37:48 -0700 (PDT) Received: from localhost.localdomain ([201.82.207.53]) by mx.google.com with ESMTPSA id s17sm45383538vdg.5.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Oct 2013 13:37:48 -0700 (PDT) From: Fabio Estevam To: cjb@laptop.org Cc: shawn.guo@linaro.org, linux-mmc@vger.kernel.org, Fabio Estevam Subject: [PATCH v2] mmc: sdhci-esdhc-imx: Check the return value from clk_prepare_enable() Date: Wed, 9 Oct 2013 17:37:39 -0300 Message-Id: <1381351059-30650-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.8.1.2 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.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: Fabio Estevam 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 funct Signed-off-by: Fabio Estevam Acked-by: Shawn Guo --- Changes since v1: - Fix the naming scheme of goto labels drivers/mmc/host/sdhci-esdhc-imx.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index b9899e9..32b0586 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -877,14 +877,22 @@ 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 disable_clk_per; + + err = clk_prepare_enable(imx_data->clk_ahb); + if (err) + goto disable_clk_ipg; imx_data->pinctrl = devm_pinctrl_get(&pdev->dev); if (IS_ERR(imx_data->pinctrl)) { err = PTR_ERR(imx_data->pinctrl); - goto disable_clk; + goto disable_clk_ahb; } imx_data->pins_default = pinctrl_lookup_state(imx_data->pinctrl, @@ -892,7 +900,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) if (IS_ERR(imx_data->pins_default)) { err = PTR_ERR(imx_data->pins_default); dev_err(mmc_dev(host->mmc), "could not get default state\n"); - goto disable_clk; + goto disable_clk_ahb; } host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; @@ -917,7 +925,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) if (!host->mmc->parent->platform_data) { dev_err(mmc_dev(host->mmc), "no board data!\n"); err = -EINVAL; - goto disable_clk; + goto disable_clk_ahb; } imx_data->boarddata = *((struct esdhc_platform_data *) host->mmc->parent->platform_data); @@ -929,7 +937,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) if (err) { dev_err(mmc_dev(host->mmc), "failed to request write-protect gpio!\n"); - goto disable_clk; + goto disable_clk_ahb; } host->mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; } @@ -941,7 +949,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) if (err) { dev_err(mmc_dev(host->mmc), "failed to request card-detect gpio!\n"); - goto disable_clk; + goto disable_clk_ahb; } /* fall through */ @@ -990,14 +998,16 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) err = sdhci_add_host(host); if (err) - goto disable_clk; + goto disable_clk_ahb; return 0; -disable_clk: - clk_disable_unprepare(imx_data->clk_per); - clk_disable_unprepare(imx_data->clk_ipg); +disable_clk_ahb: clk_disable_unprepare(imx_data->clk_ahb); +disable_clk_ipg: + clk_disable_unprepare(imx_data->clk_ipg); +disable_clk_per: + 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);