]> www.infradead.org Git - users/hch/uuid.git/commitdiff
mmc: tmio: move runtime PM enablement to the driver implementations
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Wed, 10 Apr 2019 22:22:40 +0000 (00:22 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 10 Jun 2019 15:09:56 +0000 (17:09 +0200)
Both the Renesas and Uniphier implementations perform actions which
affect runtime PM before calling into the core tmio_mmc_host_probe()
which enabled runtime PM. Move pm_runtime_enable() from the core and
tmio_mmc_host_probe() into each drivers probe() so it can be called
before any clocks or other resources are switched on.

Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/renesas_sdhi_core.c
drivers/mmc/host/tmio_mmc.c
drivers/mmc/host/tmio_mmc_core.c
drivers/mmc/host/uniphier-sd.c

index 5e9e36ed2107a01ca5da7aafe5d6a68c20ef2eb5..db73f9f1b186f0ff73da066a4f361b84e41ba525 100644 (file)
@@ -770,6 +770,8 @@ int renesas_sdhi_probe(struct platform_device *pdev,
        /* All SDHI have SDIO status bits which must be 1 */
        mmc_data->flags |= TMIO_MMC_SDIO_STATUS_SETBITS;
 
+       pm_runtime_enable(&pdev->dev);
+
        ret = renesas_sdhi_clk_enable(host);
        if (ret)
                goto efree;
@@ -850,6 +852,8 @@ edisclk:
 efree:
        tmio_mmc_host_free(host);
 
+       pm_runtime_disable(&pdev->dev);
+
        return ret;
 }
 EXPORT_SYMBOL_GPL(renesas_sdhi_probe);
@@ -861,6 +865,8 @@ int renesas_sdhi_remove(struct platform_device *pdev)
        tmio_mmc_host_remove(host);
        renesas_sdhi_clk_disable(host);
 
+       pm_runtime_disable(&pdev->dev);
+
        return 0;
 }
 EXPORT_SYMBOL_GPL(renesas_sdhi_remove);
index 93e83ad25976e756bdb04408b51c506925b02534..8539e10784b4096186024319c18f0df4e555e435 100644 (file)
@@ -172,6 +172,8 @@ static int tmio_mmc_probe(struct platform_device *pdev)
        host->mmc->f_max = pdata->hclk;
        host->mmc->f_min = pdata->hclk / 512;
 
+       pm_runtime_enable(&pdev->dev);
+
        ret = tmio_mmc_host_probe(host);
        if (ret)
                goto host_free;
@@ -191,6 +193,7 @@ host_remove:
        tmio_mmc_host_remove(host);
 host_free:
        tmio_mmc_host_free(host);
+       pm_runtime_disable(&pdev->dev);
 cell_disable:
        if (cell->disable)
                cell->disable(pdev);
@@ -207,6 +210,8 @@ static int tmio_mmc_remove(struct platform_device *pdev)
        if (cell->disable)
                cell->disable(pdev);
 
+       pm_runtime_disable(&pdev->dev);
+
        return 0;
 }
 
index 84cb7d2aacdf0a999e6e84fe172de73ca46bc611..83fd94341113cadb6fe08af10d08d94131a1e72a 100644 (file)
@@ -1153,6 +1153,15 @@ void tmio_mmc_host_free(struct tmio_mmc_host *host)
 }
 EXPORT_SYMBOL_GPL(tmio_mmc_host_free);
 
+/**
+ * tmio_mmc_host_probe() - Common probe for all implementations
+ * @_host: Host to probe
+ *
+ * Perform tasks common to all implementations probe functions.
+ *
+ * The caller should have called pm_runtime_enable() prior to calling
+ * the common probe function.
+ */
 int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
 {
        struct platform_device *pdev = _host->pdev;
@@ -1261,7 +1270,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
        pm_runtime_set_active(&pdev->dev);
        pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
        pm_runtime_use_autosuspend(&pdev->dev);
-       pm_runtime_enable(&pdev->dev);
 
        ret = mmc_add_host(mmc);
        if (ret)
@@ -1297,7 +1305,6 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
 
        pm_runtime_dont_use_autosuspend(&pdev->dev);
        pm_runtime_put_sync(&pdev->dev);
-       pm_runtime_disable(&pdev->dev);
 }
 EXPORT_SYMBOL_GPL(tmio_mmc_host_remove);
 
index 91a2be41edf6196bd9fc7f73262ab206efa46d1f..49aad9a79c18d24aba0d45340964d24b5656aeb9 100644 (file)
@@ -631,6 +631,7 @@ static int uniphier_sd_probe(struct platform_device *pdev)
        host->clk_disable = uniphier_sd_clk_disable;
        host->set_clock = uniphier_sd_set_clock;
 
+       pm_runtime_enable(&pdev->dev);
        ret = uniphier_sd_clk_enable(host);
        if (ret)
                goto free_host;
@@ -652,6 +653,7 @@ static int uniphier_sd_probe(struct platform_device *pdev)
 
 free_host:
        tmio_mmc_host_free(host);
+       pm_runtime_disable(&pdev->dev);
 
        return ret;
 }
@@ -662,6 +664,7 @@ static int uniphier_sd_remove(struct platform_device *pdev)
 
        tmio_mmc_host_remove(host);
        uniphier_sd_clk_disable(host);
+       pm_runtime_disable(&pdev->dev);
 
        return 0;
 }