Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751506AbdFEK6y (ORCPT ); Mon, 5 Jun 2017 06:58:54 -0400 Received: from mga07.intel.com ([134.134.136.100]:27916 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751293AbdFEK6x (ORCPT ); Mon, 5 Jun 2017 06:58:53 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,300,1493708400"; d="scan'208";a="95671350" Subject: Re: [PATCH] mmc: sdhci: Handle return value of clk_prepare_enable To: Arvind Yadav , ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org References: <96cf6861af2a91afd7f836f6abcc4d35aa9bb449.1496658958.git.arvind.yadav.cs@gmail.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: Date: Mon, 5 Jun 2017 13:52:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <96cf6861af2a91afd7f836f6abcc4d35aa9bb449.1496658958.git.arvind.yadav.cs@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2713 Lines: 84 On 05/06/17 13:48, Arvind Yadav wrote: > clk_prepare_enable() can fail here and we must check its return value. > > Signed-off-by: Arvind Yadav It has already been done. Check the 'next' branch in the mmc tree: git git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git > --- > drivers/mmc/host/sdhci-esdhc-imx.c | 40 ++++++++++++++++++++++++++++++-------- > 1 file changed, 32 insertions(+), 8 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c > index 23d8b8a..9ab64e73 100644 > --- a/drivers/mmc/host/sdhci-esdhc-imx.c > +++ b/drivers/mmc/host/sdhci-esdhc-imx.c > @@ -1250,9 +1250,17 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) > > pltfm_host->clk = imx_data->clk_per; > pltfm_host->clock = clk_get_rate(pltfm_host->clk); > - 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 free_clk_per; > + > + err = clk_prepare_enable(imx_data->clk_ahb); > + if (err) > + goto free_clk_ipg; > > imx_data->pinctrl = devm_pinctrl_get(&pdev->dev); > if (IS_ERR(imx_data->pinctrl)) { > @@ -1314,9 +1322,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); > +free_clk_ipg: > + clk_disable_unprepare(imx_data->clk_ipg); > +free_clk_per: > + clk_disable_unprepare(imx_data->clk_per); > free_sdhci: > sdhci_pltfm_free(pdev); > return err; > @@ -1393,14 +1403,28 @@ static int sdhci_esdhc_runtime_resume(struct device *dev) > struct sdhci_host *host = dev_get_drvdata(dev); > struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); > struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); > + int ret; > > if (!sdhci_sdio_irq_enabled(host)) { > - clk_prepare_enable(imx_data->clk_per); > - clk_prepare_enable(imx_data->clk_ipg); > + ret = clk_prepare_enable(imx_data->clk_per); > + if (ret) > + return ret; > + ret = clk_prepare_enable(imx_data->clk_ipg); > + if (ret) > + goto free_clk_per; > } > - clk_prepare_enable(imx_data->clk_ahb); > + ret = clk_prepare_enable(imx_data->clk_ahb); > + if (ret) > + goto free_clk_ipg; > > return sdhci_runtime_resume_host(host); > + > +free_clk_ipg: > + clk_disable_unprepare(imx_data->clk_ipg); > +free_clk_per: > + clk_disable_unprepare(imx_data->clk_per); > + return ret; > + > } > #endif > >