summaryrefslogtreecommitdiff
path: root/drivers/hwmon/pwm-fan.c
diff options
context:
space:
mode:
authorChris Zankel <chris@zankel.net>2014-12-15 20:09:06 -0800
committerChris Zankel <chris@zankel.net>2014-12-15 20:09:06 -0800
commit865566ed33f08637c3486b4d301e96a9064ad2eb (patch)
treedfa26622c8feaa57153d87d207133f01aff5858b /drivers/hwmon/pwm-fan.c
parentc0d7aa07504a8f4abd7b02b9144c4a92b7565f45 (diff)
parentb2776bf7149bddd1f4161f14f79520f17fc1d71d (diff)
Merge tag 'v3.18' into for_next
Linux 3.18
Diffstat (limited to 'drivers/hwmon/pwm-fan.c')
-rw-r--r--drivers/hwmon/pwm-fan.c13
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)
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