[PATCH 12/17] spi: stm32-qspi: Use helper function devm_clk_get_enabled()
Pei Xiao
xiaopei01 at kylinos.cn
Thu Mar 12 02:29:04 PDT 2026
devm_clk_get() and clk_prepare_enable() can now be replaced by
devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no
longer necessary to unprepare and disable the clocks explicitly.
Simplify code.
Signed-off-by: Pei Xiao <xiaopei01 at kylinos.cn>
---
drivers/spi/spi-stm32-qspi.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
index df1bbacec90a..9ff9975edef4 100644
--- a/drivers/spi/spi-stm32-qspi.c
+++ b/drivers/spi/spi-stm32-qspi.c
@@ -819,25 +819,19 @@ static int stm32_qspi_probe(struct platform_device *pdev)
init_completion(&qspi->match_completion);
- qspi->clk = devm_clk_get(dev, NULL);
+ qspi->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(qspi->clk))
- return PTR_ERR(qspi->clk);
-
+ return dev_err_probe(dev, PTR_ERR(qspi->clk),
+ "can not enable the clock\n");
qspi->clk_rate = clk_get_rate(qspi->clk);
if (!qspi->clk_rate)
return -EINVAL;
- ret = clk_prepare_enable(qspi->clk);
- if (ret) {
- dev_err(dev, "can not enable the clock\n");
- return ret;
- }
-
rstc = devm_reset_control_get_exclusive(dev, NULL);
if (IS_ERR(rstc)) {
ret = PTR_ERR(rstc);
if (ret == -EPROBE_DEFER)
- goto err_clk_disable;
+ goto err_defer;
} else {
reset_control_assert(rstc);
udelay(2);
@@ -886,8 +880,7 @@ static int stm32_qspi_probe(struct platform_device *pdev)
pm_runtime_dont_use_autosuspend(qspi->dev);
err_dma_free:
stm32_qspi_dma_free(qspi);
-err_clk_disable:
- clk_disable_unprepare(qspi->clk);
+err_defer:
return ret;
}
--
2.25.1
More information about the Linux-rockchip
mailing list