diff mbox

[1/1] thermal: Check cooling device's current state before declaring it inactive

Message ID 1356893856-26249-1-git-send-email-lambchop468@gmail.com (mailing list archive)
State Not Applicable, archived
Delegated to: Zhang Rui
Headers show

Commit Message

Alexander Lam Dec. 30, 2012, 6:57 p.m. UTC
It is possible for a cooling device to become active in between calls to
the thermal governor. An example of this is the acerhdf driver, which
can hand control of the cooling device over to the system firmware. Upon
returning control back to the thermal system, the cooling device might
be running again, so checking the current state of the cooling device is
required.

Signed-off-by: Alexander Lam <lambchop468@gmail.com>
---
 drivers/thermal/step_wise.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
index 0cd5e9f..0eeb709 100644
--- a/drivers/thermal/step_wise.c
+++ b/drivers/thermal/step_wise.c
@@ -94,16 +94,21 @@  static void update_instance_for_dethrottle(struct thermal_zone_device *tz,
 	unsigned long cur_state;
 
 	list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
-		if (instance->trip != trip ||
-			instance->target == THERMAL_NO_TARGET)
+		if (instance->trip != trip)
 			continue;
 
 		cdev = instance->cdev;
 		cdev->ops->get_cur_state(cdev, &cur_state);
 
-		instance->target = cur_state > instance->lower ?
+		cur_state = cur_state > instance->lower ?
 			    (cur_state - 1) : THERMAL_NO_TARGET;
 
+		if (cur_state == THERMAL_NO_TARGET &&
+					instance->target == THERMAL_NO_TARGET)
+			continue;
+
+		instance->target = cur_state;
+
 		/* Deactivate a passive thermal instance */
 		if (instance->target == THERMAL_NO_TARGET)
 			update_passive_instance(tz, trip_type, -1);