[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241206012605.2877412-1-zmw12306@gmail.com>
Date: Thu, 5 Dec 2024 20:26:05 -0500
From: Mingwei Zheng <zmw12306@...il.com>
To: fabrice.gasnier@...s.st.com,
ukleinek@...nel.org,
mcoquelin.stm32@...il.com,
alexandre.torgue@...s.st.com,
hierry.reding@...il.com,
lee@...nel.org
Cc: linux-pwm@...r.kernel.org,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
Mingwei Zheng <zmw12306@...il.com>,
Jiasheng Jiang <jiashengjiangcool@...il.com>
Subject: [PATCH V2] pwm: stm32-lp: Add check for clk_enable()
Add check for the return value of clk_enable() to catch the potential
error.
Fixes: e70a540b4e02 ("pwm: Add STM32 LPTimer PWM driver")
Signed-off-by: Mingwei Zheng <zmw12306@...il.com>
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@...il.com>
---
Changelog:
v1 -> v2
1. Move int ret declaration into if block.
---
drivers/pwm/pwm-stm32-lp.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c
index 989731256f50..f09d097d6284 100644
--- a/drivers/pwm/pwm-stm32-lp.c
+++ b/drivers/pwm/pwm-stm32-lp.c
@@ -167,8 +167,12 @@ static int stm32_pwm_lp_get_state(struct pwm_chip *chip,
regmap_read(priv->regmap, STM32_LPTIM_CR, &val);
state->enabled = !!FIELD_GET(STM32_LPTIM_ENABLE, val);
/* Keep PWM counter clock refcount in sync with PWM initial state */
- if (state->enabled)
- clk_enable(priv->clk);
+ if (state->enabled) {
+ int ret = clk_enable(priv->clk);
+
+ if (ret)
+ return ret;
+ }
regmap_read(priv->regmap, STM32_LPTIM_CFGR, &val);
presc = FIELD_GET(STM32_LPTIM_PRESC, val);
--
2.34.1
Powered by blists - more mailing lists