Skip to content

Commit 7ff2131

Browse files
Niklas Söderlundstorulf
authored andcommitted
mmc: tmio: move runtime PM enablement to the driver implementations
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 <[email protected]> Signed-off-by: Niklas Söderlund <[email protected]> Acked-by: Wolfram Sang <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent fdc4e75 commit 7ff2131

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

drivers/mmc/host/renesas_sdhi_core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,8 @@ int renesas_sdhi_probe(struct platform_device *pdev,
770770
/* All SDHI have SDIO status bits which must be 1 */
771771
mmc_data->flags |= TMIO_MMC_SDIO_STATUS_SETBITS;
772772

773+
pm_runtime_enable(&pdev->dev);
774+
773775
ret = renesas_sdhi_clk_enable(host);
774776
if (ret)
775777
goto efree;
@@ -850,6 +852,8 @@ int renesas_sdhi_probe(struct platform_device *pdev,
850852
efree:
851853
tmio_mmc_host_free(host);
852854

855+
pm_runtime_disable(&pdev->dev);
856+
853857
return ret;
854858
}
855859
EXPORT_SYMBOL_GPL(renesas_sdhi_probe);
@@ -861,6 +865,8 @@ int renesas_sdhi_remove(struct platform_device *pdev)
861865
tmio_mmc_host_remove(host);
862866
renesas_sdhi_clk_disable(host);
863867

868+
pm_runtime_disable(&pdev->dev);
869+
864870
return 0;
865871
}
866872
EXPORT_SYMBOL_GPL(renesas_sdhi_remove);

drivers/mmc/host/tmio_mmc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ static int tmio_mmc_probe(struct platform_device *pdev)
172172
host->mmc->f_max = pdata->hclk;
173173
host->mmc->f_min = pdata->hclk / 512;
174174

175+
pm_runtime_enable(&pdev->dev);
176+
175177
ret = tmio_mmc_host_probe(host);
176178
if (ret)
177179
goto host_free;
@@ -191,6 +193,7 @@ static int tmio_mmc_probe(struct platform_device *pdev)
191193
tmio_mmc_host_remove(host);
192194
host_free:
193195
tmio_mmc_host_free(host);
196+
pm_runtime_disable(&pdev->dev);
194197
cell_disable:
195198
if (cell->disable)
196199
cell->disable(pdev);
@@ -207,6 +210,8 @@ static int tmio_mmc_remove(struct platform_device *pdev)
207210
if (cell->disable)
208211
cell->disable(pdev);
209212

213+
pm_runtime_disable(&pdev->dev);
214+
210215
return 0;
211216
}
212217

drivers/mmc/host/tmio_mmc_core.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,15 @@ void tmio_mmc_host_free(struct tmio_mmc_host *host)
11531153
}
11541154
EXPORT_SYMBOL_GPL(tmio_mmc_host_free);
11551155

1156+
/**
1157+
* tmio_mmc_host_probe() - Common probe for all implementations
1158+
* @_host: Host to probe
1159+
*
1160+
* Perform tasks common to all implementations probe functions.
1161+
*
1162+
* The caller should have called pm_runtime_enable() prior to calling
1163+
* the common probe function.
1164+
*/
11561165
int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
11571166
{
11581167
struct platform_device *pdev = _host->pdev;
@@ -1261,7 +1270,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
12611270
pm_runtime_set_active(&pdev->dev);
12621271
pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
12631272
pm_runtime_use_autosuspend(&pdev->dev);
1264-
pm_runtime_enable(&pdev->dev);
12651273

12661274
ret = mmc_add_host(mmc);
12671275
if (ret)
@@ -1297,7 +1305,6 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
12971305

12981306
pm_runtime_dont_use_autosuspend(&pdev->dev);
12991307
pm_runtime_put_sync(&pdev->dev);
1300-
pm_runtime_disable(&pdev->dev);
13011308
}
13021309
EXPORT_SYMBOL_GPL(tmio_mmc_host_remove);
13031310

drivers/mmc/host/uniphier-sd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@ static int uniphier_sd_probe(struct platform_device *pdev)
631631
host->clk_disable = uniphier_sd_clk_disable;
632632
host->set_clock = uniphier_sd_set_clock;
633633

634+
pm_runtime_enable(&pdev->dev);
634635
ret = uniphier_sd_clk_enable(host);
635636
if (ret)
636637
goto free_host;
@@ -652,6 +653,7 @@ static int uniphier_sd_probe(struct platform_device *pdev)
652653

653654
free_host:
654655
tmio_mmc_host_free(host);
656+
pm_runtime_disable(&pdev->dev);
655657

656658
return ret;
657659
}
@@ -662,6 +664,7 @@ static int uniphier_sd_remove(struct platform_device *pdev)
662664

663665
tmio_mmc_host_remove(host);
664666
uniphier_sd_clk_disable(host);
667+
pm_runtime_disable(&pdev->dev);
665668

666669
return 0;
667670
}

0 commit comments

Comments
 (0)