public inbox for linux-spi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: atcspi200: Use helper function devm_clk_get_enabled()
@ 2026-03-10  8:53 Pei Xiao
  2026-03-10 17:51 ` Mark Brown
  2026-03-10 20:43 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Pei Xiao @ 2026-03-10  8:53 UTC (permalink / raw)
  To: cl634, broonie, linux-spi, linux-kernel; +Cc: Pei Xiao

Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
and enabled clocks"), devm_clk_get() and clk_prepare_enable() can now be
replaced by devm_clk_get_enabled(). Moreover, it is no longer necessary to
unprepare and disable the clocks explicitly.

Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
 drivers/spi/spi-atcspi200.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/drivers/spi/spi-atcspi200.c b/drivers/spi/spi-atcspi200.c
index 2075058387f3..6d4f3ff3d602 100644
--- a/drivers/spi/spi-atcspi200.c
+++ b/drivers/spi/spi-atcspi200.c
@@ -486,11 +486,6 @@ static int atcspi_init_resources(struct platform_device *pdev,
 		return dev_err_probe(spi->dev, PTR_ERR(spi->regmap),
 				     "Failed to init regmap\n");
 
-	spi->clk = devm_clk_get(spi->dev, NULL);
-	if (IS_ERR(spi->clk))
-		return dev_err_probe(spi->dev, PTR_ERR(spi->clk),
-				     "Failed to get SPI clock\n");
-
 	spi->sclk_rate = ATCSPI_MAX_SPEED_HZ;
 	return 0;
 }
@@ -528,11 +523,10 @@ static int atcspi_enable_clk(struct atcspi_dev *spi)
 {
 	int ret;
 
-	ret = clk_prepare_enable(spi->clk);
-	if (ret)
-		return dev_err_probe(spi->dev, ret,
-				     "Failed to enable clock\n");
-
+	spi->clk = devm_clk_get_enabled(spi->dev, NULL);
+	if (IS_ERR(spi->clk))
+		return dev_err_probe(spi->dev, PTR_ERR(spi->clk),
+				     "Failed to get SPI clock\n");
 	spi->clk_rate = clk_get_rate(spi->clk);
 	if (!spi->clk_rate)
 		return dev_err_probe(spi->dev, -EINVAL,
@@ -582,17 +576,12 @@ static int atcspi_probe(struct platform_device *pdev)
 		goto free_controller;
 
 	atcspi_init_controller(pdev, spi, host, mem_res);
-
-	ret = atcspi_setup(spi);
-	if (ret)
-		goto disable_clk;
+	atcspi_setup(spi);
 
 	ret = devm_spi_register_controller(&pdev->dev, host);
-	if (ret) {
+	if (ret)
 		dev_err_probe(spi->dev, ret,
 			      "Failed to register SPI controller\n");
-		goto disable_clk;
-	}
 
 	spi->use_dma = false;
 	if (ATCSPI_DMA_SUPPORT) {
@@ -607,9 +596,6 @@ static int atcspi_probe(struct platform_device *pdev)
 
 	return 0;
 
-disable_clk:
-	clk_disable_unprepare(spi->clk);
-
 free_controller:
 	spi_controller_put(host);
 	return ret;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-10 20:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-10  8:53 [PATCH] spi: atcspi200: Use helper function devm_clk_get_enabled() Pei Xiao
2026-03-10 17:51 ` Mark Brown
2026-03-10 20:43 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox