summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pwm-fan.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-12-01 04:21:03 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-12-01 04:21:03 +0100
commitc00552ebafddfe6abb397d957004f165e010abd2 (patch)
treeb397d6773b545755ffdae7566f8b96b08ee54ebb /drivers/hwmon/pwm-fan.c
parentMerge tag 'for-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/kishon/... (diff)
parentLinux 3.18-rc7 (diff)
downloadlinux-c00552ebafddfe6abb397d957004f165e010abd2.tar.xz
linux-c00552ebafddfe6abb397d957004f165e010abd2.zip
Merge 3.18-rc7 into usb-next
We need the xhci fixes here and this resolves a merge issue with drivers/usb/dwc3/ep0.c Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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