* [PATCH] hwmon: (pwm-fan) Explicitly switch off fan power when setting pwm1_enable to 0
@ 2022-10-13 13:59 Matthias Schiffer
2022-10-14 16:51 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Matthias Schiffer @ 2022-10-13 13:59 UTC (permalink / raw)
To: Jean Delvare, Guenter Roeck
Cc: Alexander Stein, linux-hwmon, linux-kernel, Matthias Schiffer
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>
---
drivers/hwmon/pwm-fan.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hwmon: (pwm-fan) Explicitly switch off fan power when setting pwm1_enable to 0
2022-10-13 13:59 [PATCH] hwmon: (pwm-fan) Explicitly switch off fan power when setting pwm1_enable to 0 Matthias Schiffer
@ 2022-10-14 16:51 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2022-10-14 16:51 UTC (permalink / raw)
To: Matthias Schiffer
Cc: Jean Delvare, Alexander Stein, linux-hwmon, linux-kernel
On Thu, Oct 13, 2022 at 03:59:51PM +0200, Matthias Schiffer wrote:
> 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>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/pwm-fan.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> 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);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-14 16:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-13 13:59 [PATCH] hwmon: (pwm-fan) Explicitly switch off fan power when setting pwm1_enable to 0 Matthias Schiffer
2022-10-14 16:51 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox