Skip to content

Commit

Permalink
hwmon: (pwm-fan) Explicitly switch off fan power when setting pwm1_en…
Browse files Browse the repository at this point in the history
…able 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 <matthias.schiffer@ew.tq-group.com>
Link: https://lore.kernel.org/r/20221013135951.4902-1-matthias.schiffer@ew.tq-group.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
schiffermtq authored and groeck committed Oct 16, 2022
1 parent b629102 commit 3008d20
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/hwmon/pwm-fan.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,10 @@ static int pwm_fan_update_enable(struct pwm_fan_ctx *ctx, long val)

if (val == 0) {
/* Disable pwm-fan unconditionally */
ret = __set_pwm(ctx, 0);
if (ctx->enabled)
ret = __set_pwm(ctx, 0);
else
ret = pwm_fan_switch_power(ctx, false);
if (ret)
ctx->enable_mode = old_val;
pwm_fan_update_state(ctx, 0);
Expand Down

0 comments on commit 3008d20

Please sign in to comment.