Skip to content

Commit 63e555d

Browse files
Ciprian Costeastorulf
authored andcommitted
mmc: sdhci-esdhc-imx: obtain the 'per' clock rate after its enablement
The I.MX SDHCI driver assumes that the frequency of the 'per' clock can be obtained even on disabled clocks, which is not always the case. According to 'clk_get_rate' documentation, it is only valid once the clock source has been enabled. Signed-off-by: Ciprian Costea <ciprianmarian.costea@oss.nxp.com> Reviewed-by: Haibo Chen <haibo.chen@nxp.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Link: https://lore.kernel.org/r/20240708121018.246476-3-ciprianmarian.costea@oss.nxp.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent a52b67b commit 63e555d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/mmc/host/sdhci-esdhc-imx.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,6 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
17091709
}
17101710

17111711
pltfm_host->clk = imx_data->clk_per;
1712-
pltfm_host->clock = clk_get_rate(pltfm_host->clk);
17131712
err = clk_prepare_enable(imx_data->clk_per);
17141713
if (err)
17151714
goto free_sdhci;
@@ -1720,6 +1719,13 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
17201719
if (err)
17211720
goto disable_ipg_clk;
17221721

1722+
pltfm_host->clock = clk_get_rate(pltfm_host->clk);
1723+
if (!pltfm_host->clock) {
1724+
dev_err(mmc_dev(host->mmc), "could not get clk rate\n");
1725+
err = -EINVAL;
1726+
goto disable_ahb_clk;
1727+
}
1728+
17231729
imx_data->pinctrl = devm_pinctrl_get(&pdev->dev);
17241730
if (IS_ERR(imx_data->pinctrl))
17251731
dev_warn(mmc_dev(host->mmc), "could not get pinctrl\n");

0 commit comments

Comments
 (0)