[PATCH v5 10/17] spi: slave-mt27xx: Simplify clock handling with devm_clk_get_enabled()

Pei Xiao
2026-03-19T22:38:49Z

devm_clk_get_enabled() for the "spi" 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.

Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
drivers/spi/spi-slave-mt27xx.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/spi/spi-slave-mt27xx.c b/drivers/spi/spi-slave-mt27xx.c
index ce889cb33228..8ec886918165 100644
--- a/drivers/spi/spi-slave-mt27xx.c
+++ b/drivers/spi/spi-slave-mt27xx.c
@@ -438,19 +438,13 @@ static int mtk_spi_slave_probe(struct platform_device *pdev)
goto err_put_ctlr;
}

- mdata->spi_clk = devm_clk_get(&pdev->dev, "spi");
+ mdata->spi_clk = devm_clk_get_enabled(&pdev->dev, "spi");
if (IS_ERR(mdata->spi_clk)) {
ret = PTR_ERR(mdata->spi_clk);
dev_err(&pdev->dev, "failed to get spi-clk: %d\n", ret);
goto err_put_ctlr;
}

- ret = clk_prepare_enable(mdata->spi_clk);
- if (ret < 0) {
- dev_err(&pdev->dev, "failed to enable spi_clk (%d)\n", ret);
- goto err_put_ctlr;
- }
-
pm_runtime_enable(&pdev->dev);

ret = devm_spi_register_controller(&pdev->dev, ctlr);
--
2.25.1