Commit 88ac2a2c authored by Ulf Hansson's avatar Ulf Hansson

mmc: sh_mmcif: Make sure the device stays active when needed in ->probe()

While accessing the device, make sure it stays active by increasing the
runtime PM usage count for it.

Let's also defer to enable runtime PM until we really need access to the
device. This also enables the error path in ->probe() to become simpler.
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 04974df8
...@@ -1519,23 +1519,23 @@ static int sh_mmcif_probe(struct platform_device *pdev) ...@@ -1519,23 +1519,23 @@ static int sh_mmcif_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, host); platform_set_drvdata(pdev, host);
pm_runtime_enable(dev);
host->power = false;
host->clk = devm_clk_get(dev, NULL); host->clk = devm_clk_get(dev, NULL);
if (IS_ERR(host->clk)) { if (IS_ERR(host->clk)) {
ret = PTR_ERR(host->clk); ret = PTR_ERR(host->clk);
dev_err(dev, "cannot get clock: %d\n", ret); dev_err(dev, "cannot get clock: %d\n", ret);
goto err_pm; goto err_host;
} }
ret = clk_prepare_enable(host->clk); ret = clk_prepare_enable(host->clk);
if (ret < 0) if (ret < 0)
goto err_pm; goto err_host;
sh_mmcif_clk_setup(host); sh_mmcif_clk_setup(host);
ret = pm_runtime_resume(dev); pm_runtime_enable(dev);
host->power = false;
ret = pm_runtime_get_sync(dev);
if (ret < 0) if (ret < 0)
goto err_clk; goto err_clk;
...@@ -1579,12 +1579,13 @@ static int sh_mmcif_probe(struct platform_device *pdev) ...@@ -1579,12 +1579,13 @@ static int sh_mmcif_probe(struct platform_device *pdev)
sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0xffff, sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0xffff,
clk_get_rate(host->clk) / 1000000UL); clk_get_rate(host->clk) / 1000000UL);
pm_runtime_put(dev);
clk_disable_unprepare(host->clk); clk_disable_unprepare(host->clk);
return ret; return ret;
err_clk: err_clk:
clk_disable_unprepare(host->clk); clk_disable_unprepare(host->clk);
err_pm: pm_runtime_put_sync(dev);
pm_runtime_disable(dev); pm_runtime_disable(dev);
err_host: err_host:
mmc_free_host(mmc); mmc_free_host(mmc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment