diff options
author | Matthias Schiffer <matthias.schiffer@ew.tq-group.com> | 2022-10-13 15:59:51 +0200 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2022-10-16 15:52:59 -0700 |
commit | 3008d20f5445ee6f214e3b2d42114c8c923d9625 (patch) | |
tree | 09f302cd9603d5ca6078c9cf292b7403440440de | |
parent | b6291023f659482fdb25f8ee5ab00c74682e658c (diff) | |
download | linux-stable-3008d20f5445ee6f214e3b2d42114c8c923d9625.tar.gz linux-stable-3008d20f5445ee6f214e3b2d42114c8c923d9625.tar.bz2 linux-stable-3008d20f5445ee6f214e3b2d42114c8c923d9625.zip |
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: b99152d4f04b ("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>
-rw-r--r-- | drivers/hwmon/pwm-fan.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index dc3d9a22d917..83a347ca35da 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -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); |