From: Hari Prasath Gujulan Elango <Hari.PrasathGE@microchip.com>
To: <thierry.reding@gmail.com>, <u.kleine-koenig@pengutronix.de>,
<nicolas.ferre@microchip.com>, <alexandre.belloni@bootlin.com>,
<claudiu.beznea@tuxon.dev>
Cc: <linux-pwm@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
Hari Prasath Gujulan Elango <Hari.PrasathGE@microchip.com>
Subject: [PATCH v2] pwm: atmel: add missing clk_disable_unprepare()
Date: Sat, 2 Sep 2023 12:02:32 +0530 [thread overview]
Message-ID: <20230902063232.22620-1-Hari.PrasathGE@microchip.com> (raw)
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
next reply other threads:[~2023-09-02 6:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-02 6:32 Hari Prasath Gujulan Elango [this message]
2023-09-02 16:27 ` [PATCH v2] pwm: atmel: add missing clk_disable_unprepare() Christophe JAILLET
2023-09-06 6:15 ` Hari.PrasathGE
2023-12-04 11:51 ` Uwe Kleine-König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230902063232.22620-1-Hari.PrasathGE@microchip.com \
--to=hari.prasathge@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.beznea@tuxon.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).