Skip to contentSkip to conversation

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

PATCH Applied Kamil Debski 2 participants 2 messages Nov 3, 2014 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/hwmon/pwm-fan.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/hwmon/pwm-fan.c +10 -3
index 823c877..1991d903 100644
@@ -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
 
Signature · 7 lines
1.7.9.5


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors