Skip to contentSkip to conversation

hwmon: (pwm-fan) Ensure the fan going on in .probe()

PATCH In review Billy Tsai 3 participants 3 messages Nov 30, 2021

Subsystems (2)
lore
Share & tools
lore

Billy Tsai

author
#0 lore raw

PATCH 1/1 hwmon: (pwm-fan) Ensure the fan going on in .probe()

Before commit 86585c61972f ("hwmon: (pwm-fan) stop using legacy PWM functions and some cleanups") pwm_apply_state() was called unconditionally in pwm_fan_probe(). In this commit this direct call was replaced by a call to __set_pwm(ct, MAX_PWM) which however is a noop if ctx->pwm_value already matches the value to set.
After probe the fan is supposed to run at full speed, and the internal driver state suggests it does, but this isn't asserted and depending on bootloader and pwm low-level driver, the fan might just be off.
So drop setting pwm_value to MAX_PWM to ensure the check in __set_pwm doesn't make it exit early and the fan goes on as intended.

Fixes 86585c61972f ("hwmon: (pwm-fan) stop using legacy PWM functions and some cleanups")
---
 drivers/hwmon/pwm-fan.c | 2 --
 1 file changed, 2 deletions(-)
drivers/hwmon/pwm-fan.c +0 -2
index 17518b4cab1b..f12b9a28a232 100644
@@ -336,8 +336,6 @@ static int pwm_fan_probe(struct platform_device *pdev)
 			return ret;
 	}
 
-	ctx->pwm_value = MAX_PWM;
-
 	pwm_init_state(ctx->pwm, &ctx->pwm_state);
 
 	/*
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Billy Tsai

Before commit 86585c61972f ("hwmon: (pwm-fan) stop using legacy PWM functions and some cleanups") pwm_apply_state() was called unconditionally in pwm_fan_probe(). In this commit this direct call was replaced by a call to __set_pwm(ct, MAX_PWM) which however is a noop if ctx->pwm_value already matches the value to set.
After probe the fan is supposed to run at full speed, and the internal driver state suggests it does, but this isn't asserted and depending on bootloader and pwm low-level driver, the fan might just be off.
So drop setting pwm_value to MAX_PWM to ensure the check in __set_pwm doesn't make it exit early and the fan goes on as intended.

Quoted 3 lines
Fixes 86585c61972f ("hwmon: (pwm-fan) stop using legacy PWM functions and some cleanups")

Nice commit log :-)

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
maintainer
#2 lore raw
In reply to Billy Tsai
Quoted 14 lines · Billy Tsai

Before commit 86585c61972f ("hwmon: (pwm-fan) stop using legacy PWM functions and some cleanups") pwm_apply_state() was called unconditionally in pwm_fan_probe(). In this commit this direct call was replaced by a call to __set_pwm(ct, MAX_PWM) which however is a noop if ctx->pwm_value already matches the value to set.
After probe the fan is supposed to run at full speed, and the internal driver state suggests it does, but this isn't asserted and depending on bootloader and pwm low-level driver, the fan might just be off.
So drop setting pwm_value to MAX_PWM to ensure the check in __set_pwm doesn't make it exit early and the fan goes on as intended.

Quoted 3 lines
Fixes 86585c61972f ("hwmon: (pwm-fan) stop using legacy PWM functions and some cleanups")

I'll apply this patch, but _please_ version your patches in the future and provide a change log.

Guenter

Quoted 18 lines
---
  drivers/hwmon/pwm-fan.c | 2 --
  1 file changed, 2 deletions(-)
drivers/hwmon/pwm-fan.c +0 -2
index 17518b4cab1b..f12b9a28a232 100644
@@ -336,8 +336,6 @@ static int pwm_fan_probe(struct platform_device *pdev)
  			return ret;
  	}
 
-	ctx->pwm_value = MAX_PWM;
-
  	pwm_init_state(ctx->pwm, &ctx->pwm_state);
 
  	/*