[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240827074857.2671808-9-xirui.zhang@vivo.com>
Date: Tue, 27 Aug 2024 01:48:46 -0600
From: zhangxirui <xirui.zhang@...o.com>
To: Robert Richter <rric@...nel.org>,
Ulf Hansson <ulf.hansson@...aro.org>,
Jaehoon Chung <jh80.chung@...sung.com>,
Nicolas Pitre <nico@...xnic.net>,
Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Taichi Sugaya <sugaya.taichi@...ionext.com>,
Takao Orito <orito.takao@...ionext.com>,
Michal Simek <michal.simek@....com>,
zhangxirui <xirui.zhang@...o.com>,
Linus Walleij <linus.walleij@...aro.org>,
Bastien Curutchet <bastien.curutchet@...tlin.com>,
Uwe Kleine-König <u.kleine-koenig@...gutronix.de>,
linux-mmc@...r.kernel.org,
linux-kernel@...r.kernel.org,
imx@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org
Subject: [PATCH 8/9] mmc: sdhci-of-arasan: Use devm_clk_get_enabled() helpers
Use devm_clk_get_enabled() to simplify code
and avoids the calls to clk_disable_unprepare().
Signed-off-by: zhangxirui <xirui.zhang@...o.com>
---
drivers/mmc/host/sdhci-of-arasan.c | 31 +++++-------------------------
1 file changed, 5 insertions(+), 26 deletions(-)
diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
index 5edd024347bd..f6458804ea0f 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -1875,45 +1875,33 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
sdhci_get_of_property(pdev);
- sdhci_arasan->clk_ahb = devm_clk_get(dev, "clk_ahb");
+ sdhci_arasan->clk_ahb = devm_clk_get_enabled(dev, "clk_ahb");
if (IS_ERR(sdhci_arasan->clk_ahb)) {
ret = dev_err_probe(dev, PTR_ERR(sdhci_arasan->clk_ahb),
"clk_ahb clock not found.\n");
goto err_pltfm_free;
}
- clk_xin = devm_clk_get(dev, "clk_xin");
+ clk_xin = devm_clk_get_enabled(dev, "clk_xin");
if (IS_ERR(clk_xin)) {
ret = dev_err_probe(dev, PTR_ERR(clk_xin), "clk_xin clock not found.\n");
goto err_pltfm_free;
}
- ret = clk_prepare_enable(sdhci_arasan->clk_ahb);
- if (ret) {
- dev_err(dev, "Unable to enable AHB clock.\n");
- goto err_pltfm_free;
- }
-
/* If clock-frequency property is set, use the provided value */
if (pltfm_host->clock &&
pltfm_host->clock != clk_get_rate(clk_xin)) {
ret = clk_set_rate(clk_xin, pltfm_host->clock);
if (ret) {
dev_err(&pdev->dev, "Failed to set SD clock rate\n");
- goto clk_dis_ahb;
+ goto err_pltfm_free;
}
}
- ret = clk_prepare_enable(clk_xin);
- if (ret) {
- dev_err(dev, "Unable to enable SD clock.\n");
- goto clk_dis_ahb;
- }
-
clk_dll = devm_clk_get_optional_enabled(dev, "gate");
if (IS_ERR(clk_dll)) {
ret = dev_err_probe(dev, PTR_ERR(clk_dll), "failed to get dll clk\n");
- goto clk_disable_all;
+ goto err_pltfm_free;
}
if (of_property_read_bool(np, "xlnx,fails-without-test-cd"))
@@ -1940,7 +1928,7 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
ret = sdhci_arasan_register_sdclk(sdhci_arasan, clk_xin, dev);
if (ret)
- goto clk_disable_all;
+ goto err_pltfm_free;
if (of_device_is_compatible(np, "xlnx,zynqmp-8.9a")) {
host->mmc_host_ops.execute_tuning =
@@ -2007,10 +1995,6 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
phy_exit(sdhci_arasan->phy);
unreg_clk:
sdhci_arasan_unregister_sdclk(dev);
-clk_disable_all:
- clk_disable_unprepare(clk_xin);
-clk_dis_ahb:
- clk_disable_unprepare(sdhci_arasan->clk_ahb);
err_pltfm_free:
sdhci_pltfm_free(pdev);
return ret;
@@ -2021,8 +2005,6 @@ static void sdhci_arasan_remove(struct platform_device *pdev)
struct sdhci_host *host = platform_get_drvdata(pdev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
- struct clk *clk_ahb = sdhci_arasan->clk_ahb;
- struct clk *clk_xin = pltfm_host->clk;
if (!IS_ERR(sdhci_arasan->phy)) {
if (sdhci_arasan->is_phy_on)
@@ -2033,9 +2015,6 @@ static void sdhci_arasan_remove(struct platform_device *pdev)
sdhci_arasan_unregister_sdclk(&pdev->dev);
sdhci_pltfm_remove(pdev);
-
- clk_disable_unprepare(clk_xin);
- clk_disable_unprepare(clk_ahb);
}
static struct platform_driver sdhci_arasan_driver = {
--
2.25.1
Powered by blists - more mailing lists