mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pei Xiao <xiaopei01@kylinos.cn>
To: linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, imx@lists.linux.dev,
	openbmc@lists.ozlabs.org, linux-rockchip@lists.infradead.org,
	linux-riscv@lists.infradead.org,
	linux-mediatek@lists.infradead.org,
	linux-stm32@st-md-mailman.stormreply.com
Cc: Pei Xiao <xiaopei01@kylinos.cn>
Subject: [PATCH v4 07/17] spi: orion: Simplify clock handling with devm_clk_get_enabled()
Date: Wed, 18 Mar 2026 10:39:57 +0800	[thread overview]
Message-ID: <753e8d3343b4f880fc08628bbf8d3043c27fae5f.1773801401.git.xiaopei01@kylinos.cn> (raw)
In-Reply-To: <cover.1773801401.git.xiaopei01@kylinos.cn>

Replace devm_clk_get() followed by clk_prepare_enable() with
devm_clk_get_enabled() for the "axi" clock. This reduces
boilerplate code and error handling, as the managed API automatically
disables the clock when the device is removed or if probe fails.

Remove the now-unnecessary clk_disable_unprepare() call from the
probe error path and the remove callback. Adjust error handling labels
accordingly.

Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
 drivers/spi/spi-orion.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index 7a2186b51b4c..d884a18c95a6 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -695,13 +695,11 @@ static int orion_spi_probe(struct platform_device *pdev)
 	}
 
 	/* The following clock is only used by some SoCs */
-	spi->axi_clk = devm_clk_get(&pdev->dev, "axi");
+	spi->axi_clk = devm_clk_get_enabled(&pdev->dev, "axi");
 	if (PTR_ERR(spi->axi_clk) == -EPROBE_DEFER) {
 		status = -EPROBE_DEFER;
 		goto out;
 	}
-	if (!IS_ERR(spi->axi_clk))
-		clk_prepare_enable(spi->axi_clk);
 
 	tclk_hz = clk_get_rate(spi->clk);
 
@@ -726,7 +724,7 @@ static int orion_spi_probe(struct platform_device *pdev)
 	spi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
 	if (IS_ERR(spi->base)) {
 		status = PTR_ERR(spi->base);
-		goto out_rel_axi_clk;
+		goto out;
 	}
 
 	for_each_available_child_of_node(pdev->dev.of_node, np) {
@@ -764,7 +762,7 @@ static int orion_spi_probe(struct platform_device *pdev)
 		if (!dir_acc->vaddr) {
 			status = -ENOMEM;
 			of_node_put(np);
-			goto out_rel_axi_clk;
+			goto out;
 		}
 		dir_acc->size = PAGE_SIZE;
 
@@ -788,8 +786,6 @@ static int orion_spi_probe(struct platform_device *pdev)
 
 out_rel_pm:
 	pm_runtime_disable(&pdev->dev);
-out_rel_axi_clk:
-	clk_disable_unprepare(spi->axi_clk);
 out:
 	spi_controller_put(host);
 	return status;
@@ -802,7 +798,6 @@ static void orion_spi_remove(struct platform_device *pdev)
 	struct orion_spi *spi = spi_controller_get_devdata(host);
 
 	pm_runtime_get_sync(&pdev->dev);
-	clk_disable_unprepare(spi->axi_clk);
 
 	spi_unregister_controller(host);
 	pm_runtime_disable(&pdev->dev);
-- 
2.25.1


  parent reply	other threads:[~2026-03-18  2:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-18  2:39 [PATCH v4 00/17] cleanup in spi by use devm_clk_get_enabled Pei Xiao
2026-03-18  2:39 ` [PATCH v4 01/17] spi: axiado: Simplify clock management with devm_clk_get_enabled() Pei Xiao
2026-03-18  2:39 ` [PATCH v4 02/17] spi: bcm63xx-hsspi: Simplify clock handling " Pei Xiao
2026-03-18  2:39 ` [PATCH v4 03/17] spi: bcmbca-hsspi: " Pei Xiao
2026-03-18  2:39 ` [PATCH v4 04/17] spi: img-spfi: " Pei Xiao
2026-03-18  2:39 ` [PATCH v4 05/17] spi: imx: " Pei Xiao
2026-03-18 13:45   ` Frank Li
2026-03-18  2:39 ` [PATCH v4 06/17] spi: npcm-pspi: " Pei Xiao
2026-03-18  2:39 ` Pei Xiao [this message]
2026-03-18  2:39 ` [PATCH v4 08/17] spi: rockchip-sfc: " Pei Xiao
2026-03-18  2:39 ` [PATCH v4 09/17] spi: sifive: " Pei Xiao
2026-03-18  2:40 ` [PATCH v4 10/17] spi: slave-mt27xx: " Pei Xiao
2026-03-18  2:40 ` [PATCH v4 11/17] spi: st: " Pei Xiao
2026-03-18  2:40 ` [PATCH v4 12/17] spi: stm32-qspi: " Pei Xiao
2026-03-18  2:40 ` [PATCH v4 13/17] spi: stm32: " Pei Xiao
2026-03-18 17:20   ` [Linux-stm32] " Amelie Delaunay
2026-03-18  2:40 ` [PATCH v4 14/17] spi: sunplus-sp7021: " Pei Xiao
2026-03-18  2:40 ` [PATCH v4 15/17] spi: uniphier: " Pei Xiao
2026-03-18  2:40 ` [PATCH v4 16/17] spi: zynq-qspi: " Pei Xiao
2026-03-18  2:40 ` [PATCH v4 17/17] spi: zynqmp-gqspi: " Pei Xiao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=753e8d3343b4f880fc08628bbf8d3043c27fae5f.1773801401.git.xiaopei01@kylinos.cn \
    --to=xiaopei01@kylinos.cn \
    --cc=imx@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=openbmc@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®