thermal: step_wise: Fix bug on passive instance updating
Jinyoung Park [Mon, 26 Nov 2012 23:43:22 +0000 (15:43 -0800)]
Thermal passive monitoring is not working correctly due to a bug on
passive instance updating.

Bug 1059470

Change-Id: I306fc3db9756c1a411619152c868174124635d4c
Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/166388
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>

drivers/thermal/step_wise.c

index 1242cff..17c63f4 100644 (file)
@@ -71,15 +71,18 @@ static void update_instance_for_throttle(struct thermal_zone_device *tz,
                                enum thermal_trend trend)
 {
        struct thermal_instance *instance;
+       unsigned long old_target;
 
        list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
                if (instance->trip != trip)
                        continue;
 
+               old_target = instance->target;
                instance->target = get_target_state(instance, trend);
 
                /* Activate a passive thermal instance */
-               if (instance->target == THERMAL_NO_TARGET)
+               if (old_target == THERMAL_NO_TARGET &&
+                       instance->target != THERMAL_NO_TARGET)
                        update_passive_instance(tz, trip_type, 1);
 
                instance->cdev->updated = false; /* cdev needs update */
@@ -92,6 +95,7 @@ static void update_instance_for_dethrottle(struct thermal_zone_device *tz,
        struct thermal_instance *instance;
        struct thermal_cooling_device *cdev;
        unsigned long cur_state;
+       unsigned long old_target;
 
        list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
                if (instance->trip != trip ||
@@ -101,11 +105,13 @@ static void update_instance_for_dethrottle(struct thermal_zone_device *tz,
                cdev = instance->cdev;
                cdev->ops->get_cur_state(cdev, &cur_state);
 
+               old_target = instance->target;
                instance->target = cur_state > instance->lower ?
                            (cur_state - 1) : THERMAL_NO_TARGET;
 
                /* Deactivate a passive thermal instance */
-               if (instance->target == THERMAL_NO_TARGET)
+               if (old_target != THERMAL_NO_TARGET &&
+                       instance->target == THERMAL_NO_TARGET)
                        update_passive_instance(tz, trip_type, -1);
 
                cdev->updated = false; /* cdev needs update */