Skip to content

Commit 3008d20

Browse files
tq-schiffermgroeck
authored andcommitted
hwmon: (pwm-fan) Explicitly switch off fan power when setting pwm1_enable to 0
When pwm1_enable is changed from 1 to 0 while pwm1 == 0, the regulator is not switched off as expected. The reason is that when the fan is already off, ctx->enabled is false, so pwm_fan_power_off() will be a no-op. Handle this case explicitly in pwm_fan_update_enable() by calling pwm_fan_switch_power() directly. Fixes: b99152d ("hwmon: (pwm-fan) Switch regulator dynamically") Signed-off-by: Matthias Schiffer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent b629102 commit 3008d20

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/hwmon/pwm-fan.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,10 @@ static int pwm_fan_update_enable(struct pwm_fan_ctx *ctx, long val)
257257

258258
if (val == 0) {
259259
/* Disable pwm-fan unconditionally */
260-
ret = __set_pwm(ctx, 0);
260+
if (ctx->enabled)
261+
ret = __set_pwm(ctx, 0);
262+
else
263+
ret = pwm_fan_switch_power(ctx, false);
261264
if (ret)
262265
ctx->enable_mode = old_val;
263266
pwm_fan_update_state(ctx, 0);

0 commit comments

Comments
 (0)