mmc: sdhci-st: Handle return value of clk_prepare_enable
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Tue, 20 Jun 2017 11:57:00 +0000 (17:27 +0530)
committerUlf Hansson <ulf.hansson@linaro.org>
Wed, 30 Aug 2017 12:01:20 +0000 (14:01 +0200)
clk_prepare_enable() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sdhci-st.c

index 68c36c9fa23184e8c0d7e01733199089449384ab..198b4cad5e847ca5fe5ced607c16700f2d08b927 100644 (file)
@@ -394,8 +394,17 @@ static int sdhci_st_probe(struct platform_device *pdev)
                goto err_of;
        }
 
-       clk_prepare_enable(clk);
-       clk_prepare_enable(icnclk);
+       ret = clk_prepare_enable(clk);
+       if (ret) {
+               dev_err(&pdev->dev, "Failed to prepare clock\n");
+               goto err_of;
+       }
+
+       ret = clk_prepare_enable(icnclk);
+       if (ret) {
+               dev_err(&pdev->dev, "Failed to prepare icn clock\n");
+               goto err_icnclk;
+       }
 
        /* Configure the FlashSS Top registers for setting eMMC TX/RX delay */
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
@@ -429,6 +438,7 @@ static int sdhci_st_probe(struct platform_device *pdev)
 
 err_out:
        clk_disable_unprepare(icnclk);
+err_icnclk:
        clk_disable_unprepare(clk);
 err_of:
        sdhci_pltfm_free(pdev);
@@ -487,9 +497,17 @@ static int sdhci_st_resume(struct device *dev)
        struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
        struct st_mmc_platform_data *pdata = sdhci_pltfm_priv(pltfm_host);
        struct device_node *np = dev->of_node;
+       int ret;
+
+       ret = clk_prepare_enable(pltfm_host->clk);
+       if (ret)
+               return ret;
 
-       clk_prepare_enable(pltfm_host->clk);
-       clk_prepare_enable(pdata->icnclk);
+       ret = clk_prepare_enable(pdata->icnclk);
+       if (ret) {
+               clk_disable_unprepare(pltfm_host->clk);
+               return ret;
+       }
 
        if (pdata->rstc)
                reset_control_deassert(pdata->rstc);