[PATCH v8 15/16] spi: davinci: Simplify using devm_clk_get_enabled()

Uwe Kleine-König
2022-03-14T14:17:13Z

devm_clk_get_enabled() returns the clk already (prepared and) enabled
and the automatically called cleanup cares for disabling (and
unpreparing). So simplify .probe() and .remove() accordingly.

Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/spi/spi-davinci.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index d112c2cac042..5448510c285f 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -925,14 +925,11 @@ static int davinci_spi_probe(struct platform_device *pdev)

dspi->bitbang.master = master;

- dspi->clk = devm_clk_get(&pdev->dev, NULL);
+ dspi->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(dspi->clk)) {
ret = -ENODEV;
goto free_master;
}
- ret = clk_prepare_enable(dspi->clk);
- if (ret)
- goto free_master;

master->use_gpio_descriptors = true;
master->dev.of_node = pdev->dev.of_node;
@@ -957,7 +954,7 @@ static int davinci_spi_probe(struct platform_device *pdev)

ret = davinci_spi_request_dma(dspi);
if (ret == -EPROBE_DEFER) {
- goto free_clk;
+ goto free_master;
} else if (ret) {
dev_info(&pdev->dev, "DMA is not supported (%d)\n", ret);
dspi->dma_rx = NULL;
@@ -1001,8 +998,6 @@ static int davinci_spi_probe(struct platform_device *pdev)
dma_release_channel(dspi->dma_rx);
dma_release_channel(dspi->dma_tx);
}
-free_clk:
- clk_disable_unprepare(dspi->clk);
free_master:
spi_master_put(master);
err:
@@ -1028,8 +1023,6 @@ static int davinci_spi_remove(struct platform_device *pdev)

spi_bitbang_stop(&dspi->bitbang);

- clk_disable_unprepare(dspi->clk);
-
if (dspi->dma_rx) {
dma_release_channel(dspi->dma_rx);
dma_release_channel(dspi->dma_tx);
--
2.35.1