* [PATCH] hwmon: (pwm-fan) Fix suspend/resume behavior
@ 2014-11-03 14:42 Kamil Debski
2014-11-03 16:19 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Kamil Debski @ 2014-11-03 14:42 UTC (permalink / raw)
To: linux-kernel, lm-sensors; +Cc: linux, Kamil Debski
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: Kamil Debski <k.debski@samsung.com>
---
drivers/hwmon/pwm-fan.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 823c877..1991d903 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -161,10 +161,17 @@ static int pwm_fan_suspend(struct device *dev)
static int pwm_fan_resume(struct device *dev)
{
struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+ unsigned long duty;
+ int ret;
- if (ctx->pwm_value)
- return pwm_enable(ctx->pwm);
- return 0;
+ if (ctx->pwm_value == 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
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hwmon: (pwm-fan) Fix suspend/resume behavior
2014-11-03 14:42 [PATCH] hwmon: (pwm-fan) Fix suspend/resume behavior Kamil Debski
@ 2014-11-03 16:19 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2014-11-03 16:19 UTC (permalink / raw)
To: Kamil Debski; +Cc: linux-kernel, lm-sensors
On Mon, Nov 03, 2014 at 03:42:55PM +0100, Kamil Debski wrote:
> 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: Kamil Debski <k.debski@samsung.com>
Applied.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-03 16:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-03 14:42 [PATCH] hwmon: (pwm-fan) Fix suspend/resume behavior Kamil Debski
2014-11-03 16:19 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).