diff options
author | Kamil Debski <k.debski@samsung.com> | 2014-11-03 09:42:55 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2014-11-11 13:39:45 -0500 |
commit | 48b9d5b4f408259cd6800c4b17d4fe5025435da2 (patch) | |
tree | 9e6acd855c6088dd9d9dbbb2d95ccc665da4edda /drivers/hwmon | |
parent | aab18da44f243cf59b4dee335ea50b32f529b5b0 (diff) |
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: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/pwm-fan.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 823c877a1ec0..1991d9032c38 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) | |||
161 | static int pwm_fan_resume(struct device *dev) | 161 | static int pwm_fan_resume(struct device *dev) |
162 | { | 162 | { |
163 | struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); | 163 | struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); |
164 | unsigned long duty; | ||
165 | int ret; | ||
164 | 166 | ||
165 | if (ctx->pwm_value) | 167 | if (ctx->pwm_value == 0) |
166 | return pwm_enable(ctx->pwm); | 168 | return 0; |
167 | return 0; | 169 | |
170 | duty = DIV_ROUND_UP(ctx->pwm_value * (ctx->pwm->period - 1), MAX_PWM); | ||
171 | ret = pwm_config(ctx->pwm, duty, ctx->pwm->period); | ||
172 | if (ret) | ||
173 | return ret; | ||
174 | return pwm_enable(ctx->pwm); | ||
168 | } | 175 | } |
169 | #endif | 176 | #endif |
170 | 177 | ||