[PATCH v4 11/17] spi: st: Simplify clock handling with devm_clk_get_enabled()
Pei Xiao
xiaopei01 at kylinos.cn
Tue Mar 17 19:40:01 PDT 2026
Replace devm_clk_get() followed by clk_prepare_enable() with
devm_clk_get_enabled() for the clock. This removes the need for
explicit clock enable and disable calls, as the managed API automatically
handles clock disabling on device removal or probe failure.
Remove the now-unnecessary clk_disable_unprepare() calls from the probe
error path and the remove callback. Adjust error labels accordingly.
Signed-off-by: Pei Xiao <xiaopei01 at kylinos.cn>
---
drivers/spi/spi-st-ssc4.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/spi/spi-st-ssc4.c b/drivers/spi/spi-st-ssc4.c
index b173ef70d77e..0d653986499c 100644
--- a/drivers/spi/spi-st-ssc4.c
+++ b/drivers/spi/spi-st-ssc4.c
@@ -293,24 +293,20 @@ static int spi_st_probe(struct platform_device *pdev)
host->use_gpio_descriptors = true;
spi_st = spi_controller_get_devdata(host);
- spi_st->clk = devm_clk_get(&pdev->dev, "ssc");
+ spi_st->clk = devm_clk_get_enabled(&pdev->dev, "ssc");
if (IS_ERR(spi_st->clk)) {
dev_err(&pdev->dev, "Unable to request clock\n");
ret = PTR_ERR(spi_st->clk);
goto put_host;
}
- ret = clk_prepare_enable(spi_st->clk);
- if (ret)
- goto put_host;
-
init_completion(&spi_st->done);
/* Get resources */
spi_st->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(spi_st->base)) {
ret = PTR_ERR(spi_st->base);
- goto clk_disable;
+ goto put_host;
}
/* Disable I2C and Reset SSC */
@@ -333,14 +329,14 @@ static int spi_st_probe(struct platform_device *pdev)
if (!irq) {
dev_err(&pdev->dev, "IRQ missing or invalid\n");
ret = -EINVAL;
- goto clk_disable;
+ goto put_host;
}
ret = devm_request_irq(&pdev->dev, irq, spi_st_irq, 0,
pdev->name, spi_st);
if (ret) {
dev_err(&pdev->dev, "Failed to request irq %d\n", irq);
- goto clk_disable;
+ goto put_host;
}
/* by default the device is on */
@@ -359,8 +355,6 @@ static int spi_st_probe(struct platform_device *pdev)
rpm_disable:
pm_runtime_disable(&pdev->dev);
-clk_disable:
- clk_disable_unprepare(spi_st->clk);
put_host:
spi_controller_put(host);
return ret;
@@ -373,8 +367,6 @@ static void spi_st_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
- clk_disable_unprepare(spi_st->clk);
-
pinctrl_pm_select_sleep_state(&pdev->dev);
}
--
2.25.1
More information about the Linux-mediatek
mailing list