diff mbox series

[v8,16/16] dmaengine: lgm: Fix error handling

Message ID 20220314141643.22184-17-u.kleine-koenig@pengutronix.de (mailing list archive)
State Not Applicable, archived
Headers show
Series clk: provide new devm helpers for prepared and enabled clocks | expand

Commit Message

Uwe Kleine-König March 14, 2022, 2:16 p.m. UTC
It's an invalid approach to use only a single devm cleanup handler for
two resources (without further error handling at least). In this case the
core clk isn't disabled if getting the reset control fails.

This also fixes the problem that the return value of clk_prepare_enable()
wasn't checked before.

Fixes: 32d31c79a1a4 ("dmaengine: Add Intel LGM SoC DMA support.")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/dma/lgm/lgm-dma.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/dma/lgm/lgm-dma.c b/drivers/dma/lgm/lgm-dma.c
index efe8bd3a0e2a..f8904cf2d832 100644
--- a/drivers/dma/lgm/lgm-dma.c
+++ b/drivers/dma/lgm/lgm-dma.c
@@ -1463,11 +1463,10 @@  static int ldma_init_v22(struct ldma_dev *d, struct platform_device *pdev)
 	return 0;
 }
 
-static void ldma_clk_disable(void *data)
+static void ldma_reset(void *data)
 {
 	struct ldma_dev *d = data;
 
-	clk_disable_unprepare(d->core_clk);
 	reset_control_assert(d->rst);
 }
 
@@ -1590,17 +1589,16 @@  static int intel_ldma_probe(struct platform_device *pdev)
 		return PTR_ERR(d->base);
 
 	/* Power up and reset the dma engine, some DMAs always on?? */
-	d->core_clk = devm_clk_get_optional(dev, NULL);
+	d->core_clk = devm_clk_get_optional_enabled(dev, NULL);
 	if (IS_ERR(d->core_clk))
 		return PTR_ERR(d->core_clk);
-	clk_prepare_enable(d->core_clk);
 
 	d->rst = devm_reset_control_get_optional(dev, NULL);
 	if (IS_ERR(d->rst))
 		return PTR_ERR(d->rst);
 	reset_control_deassert(d->rst);
 
-	ret = devm_add_action_or_reset(dev, ldma_clk_disable, d);
+	ret = devm_add_action_or_reset(dev, ldma_reset, d);
 	if (ret) {
 		dev_err(dev, "Failed to devm_add_action_or_reset, %d\n", ret);
 		return ret;