diff mbox series

hwmon: npcm750-pwm: add an error code check in npcm7xx_en_pwm_fan

Message ID 20231020085518.198477-1-suhui@nfschina.com (mailing list archive)
State Accepted
Headers show
Series hwmon: npcm750-pwm: add an error code check in npcm7xx_en_pwm_fan | expand

Commit Message

Su Hui Oct. 20, 2023, 8:55 a.m. UTC
npcm7xx_pwm_config_set() can return '-ENODEV' for failed. So check
the value of 'ret' after calling npcm7xx_pwm_config_set().

Signed-off-by: Su Hui <suhui@nfschina.com>
---
 drivers/hwmon/npcm750-pwm-fan.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Guenter Roeck Oct. 25, 2023, 7:36 p.m. UTC | #1
On Fri, Oct 20, 2023 at 04:55:19PM +0800, Su Hui wrote:
> npcm7xx_pwm_config_set() can return '-ENODEV' for failed. So check
> the value of 'ret' after calling npcm7xx_pwm_config_set().
> 
> Signed-off-by: Su Hui <suhui@nfschina.com>

Applied.

Thanks,
Guenter
diff mbox series

Patch

diff --git a/drivers/hwmon/npcm750-pwm-fan.c b/drivers/hwmon/npcm750-pwm-fan.c
index 10ed3f4335d4..4702e4edc662 100644
--- a/drivers/hwmon/npcm750-pwm-fan.c
+++ b/drivers/hwmon/npcm750-pwm-fan.c
@@ -875,6 +875,8 @@  static int npcm7xx_en_pwm_fan(struct device *dev,
 	data->pwm_present[pwm_port] = true;
 	ret = npcm7xx_pwm_config_set(data, pwm_port,
 				     NPCM7XX_PWM_CMR_DEFAULT_NUM);
+	if (ret)
+		return ret;
 
 	ret = of_property_count_u8_elems(child, "cooling-levels");
 	if (ret > 0) {