Commit 48b9d5b4 authored by Kamil Debski's avatar Kamil Debski Committed by Guenter Roeck

hwmon: (pwm-fan) Fix suspend/resume behavior

The state of a PWM output is not clearly defined after resume. Some PWM
drivers do not restore the duty cycle upon resume, thus it is necessary to
manually restore the correct value.
Signed-off-by: default avatarKamil Debski <k.debski@samsung.com>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent aab18da4
...@@ -161,10 +161,17 @@ static int pwm_fan_suspend(struct device *dev) ...@@ -161,10 +161,17 @@ static int pwm_fan_suspend(struct device *dev)
static int pwm_fan_resume(struct device *dev) static int pwm_fan_resume(struct device *dev)
{ {
struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
unsigned long duty;
int ret;
if (ctx->pwm_value) if (ctx->pwm_value == 0)
return pwm_enable(ctx->pwm);
return 0; return 0;
duty = DIV_ROUND_UP(ctx->pwm_value * (ctx->pwm->period - 1), MAX_PWM);
ret = pwm_config(ctx->pwm, duty, ctx->pwm->period);
if (ret)
return ret;
return pwm_enable(ctx->pwm);
} }
#endif #endif
......
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