Commit ebb75a3c authored by Johannes Kirchmair's avatar Johannes Kirchmair Committed by Guenter Roeck

hwmon: (pwmfan) Do not force disable pwm controller

The pwm1_enable attribute of the pwmfan driver influences the mode of
operation, especially in case of a requested pwm1 duty cycle of zero.
Especially setting pwm1_enable to two, should keep the pwm controller
enabled even if the duty cycle is set to zero [1].

This is not the case at the moment, as the pwm controller is disabled
always if pwm1 is set to zero.

This commit tries to fix this behavior.

[1] https://docs.kernel.org/hwmon/pwm-fan.htmlSigned-off-by: default avatarJohannes Kirchmair <johannes.kirchmair@skidata.com>
Message-ID: <20240827054454.521494-1-mailinglist1@johanneskirchmair.de>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent ac9cca7a
...@@ -167,7 +167,7 @@ static int pwm_fan_power_on(struct pwm_fan_ctx *ctx) ...@@ -167,7 +167,7 @@ static int pwm_fan_power_on(struct pwm_fan_ctx *ctx)
return ret; return ret;
} }
static int pwm_fan_power_off(struct pwm_fan_ctx *ctx) static int pwm_fan_power_off(struct pwm_fan_ctx *ctx, bool force_disable)
{ {
struct pwm_state *state = &ctx->pwm_state; struct pwm_state *state = &ctx->pwm_state;
bool enable_regulator = false; bool enable_regulator = false;
...@@ -180,7 +180,8 @@ static int pwm_fan_power_off(struct pwm_fan_ctx *ctx) ...@@ -180,7 +180,8 @@ static int pwm_fan_power_off(struct pwm_fan_ctx *ctx)
state, state,
&enable_regulator); &enable_regulator);
state->enabled = false; if (force_disable)
state->enabled = false;
state->duty_cycle = 0; state->duty_cycle = 0;
ret = pwm_apply_might_sleep(ctx->pwm, state); ret = pwm_apply_might_sleep(ctx->pwm, state);
if (ret) { if (ret) {
...@@ -213,7 +214,7 @@ static int __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm) ...@@ -213,7 +214,7 @@ static int __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
return ret; return ret;
ret = pwm_fan_power_on(ctx); ret = pwm_fan_power_on(ctx);
} else { } else {
ret = pwm_fan_power_off(ctx); ret = pwm_fan_power_off(ctx, false);
} }
if (!ret) if (!ret)
ctx->pwm_value = pwm; ctx->pwm_value = pwm;
...@@ -468,7 +469,7 @@ static void pwm_fan_cleanup(void *__ctx) ...@@ -468,7 +469,7 @@ static void pwm_fan_cleanup(void *__ctx)
del_timer_sync(&ctx->rpm_timer); del_timer_sync(&ctx->rpm_timer);
/* Switch off everything */ /* Switch off everything */
ctx->enable_mode = pwm_disable_reg_disable; ctx->enable_mode = pwm_disable_reg_disable;
pwm_fan_power_off(ctx); pwm_fan_power_off(ctx, true);
} }
static int pwm_fan_probe(struct platform_device *pdev) static int pwm_fan_probe(struct platform_device *pdev)
...@@ -661,7 +662,7 @@ static int pwm_fan_suspend(struct device *dev) ...@@ -661,7 +662,7 @@ static int pwm_fan_suspend(struct device *dev)
{ {
struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
return pwm_fan_power_off(ctx); return pwm_fan_power_off(ctx, true);
} }
static int pwm_fan_resume(struct device *dev) static int pwm_fan_resume(struct device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment