mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] pwm: atmel: add missing clk_disable_unprepare()
@ 2023-09-02  6:32 Hari Prasath Gujulan Elango
  2023-09-02 16:27 ` Christophe JAILLET
  0 siblings, 1 reply; 4+ messages in thread
From: Hari Prasath Gujulan Elango @ 2023-09-02  6:32 UTC (permalink / raw)
  To: thierry.reding, u.kleine-koenig, nicolas.ferre,
	alexandre.belloni, claudiu.beznea
  Cc: linux-pwm, linux-arm-kernel, linux-kernel, Hari Prasath Gujulan Elango

Fix the below smatch warning:

drivers/pwm/pwm-atmel-hlcdc.c:167 atmel_hlcdc_pwm_apply() warn: 'new_clk' from clk_prepare_enable() not released on lines: 112,137,142,149.

'Fixes: 2b4984bef47a5 ("pwm: atmel-hlcdc: Convert to the atomic PWM API")'

Signed-off-by: Hari Prasath Gujulan Elango <Hari.PrasathGE@microchip.com>

changelog of v2:

         - moved the clk_disable_unprepare to single point of return.
         - cur_clk set to NULL before return.
---
 drivers/pwm/pwm-atmel-hlcdc.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
index 96a709a9d49a..4d35b838203f 100644
--- a/drivers/pwm/pwm-atmel-hlcdc.c
+++ b/drivers/pwm/pwm-atmel-hlcdc.c
@@ -44,7 +44,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
 	struct atmel_hlcdc_pwm *chip = to_atmel_hlcdc_pwm(c);
 	struct atmel_hlcdc *hlcdc = chip->hlcdc;
 	unsigned int status;
-	int ret;
+	int ret = 0;
 
 	if (state->enabled) {
 		struct clk *new_clk = hlcdc->slow_clk;
@@ -109,7 +109,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
 						 ATMEL_HLCDC_CLKPWMSEL,
 						 gencfg);
 			if (ret)
-				return ret;
+				goto disable_new_clk;
 		}
 
 		do_div(pwmcval, state->period);
@@ -134,18 +134,20 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm,
 					 ATMEL_HLCDC_PWMPOL,
 					 pwmcfg);
 		if (ret)
-			return ret;
+			goto disable_new_clk;
 
 		ret = regmap_write(hlcdc->regmap, ATMEL_HLCDC_EN,
 				   ATMEL_HLCDC_PWM);
 		if (ret)
-			return ret;
+			goto disable_new_clk;
 
 		ret = regmap_read_poll_timeout(hlcdc->regmap, ATMEL_HLCDC_SR,
 					       status,
 					       status & ATMEL_HLCDC_PWM,
 					       10, 0);
-		if (ret)
+disable_new_clk:
+			clk_disable_unprepare(new_clk);
+			chip->cur_clk = NULL;
 			return ret;
 	} else {
 		ret = regmap_write(hlcdc->regmap, ATMEL_HLCDC_DIS,
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-04 11:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-02  6:32 [PATCH v2] pwm: atmel: add missing clk_disable_unprepare() Hari Prasath Gujulan Elango
2023-09-02 16:27 ` Christophe JAILLET
2023-09-06  6:15   ` Hari.PrasathGE
2023-12-04 11:51     ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®