Thermal: pid_thermal_gov: Skip unncessary throttle target calculation
Jinyoung Park [Mon, 29 Apr 2013 17:18:19 +0000 (02:18 +0900)]
Skip throttle target calculation if upper state and lower state are same.

Change-Id: I36d3ed7e324225ee03b3330f7ad80f0cd3e27457
Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/223933
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Aleksandr Frid <afrid@nvidia.com>
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>

drivers/thermal/pid_thermal_gov.c

index c022255..525469a 100644 (file)
@@ -462,12 +462,14 @@ static int pid_thermal_gov_throttle(struct thermal_zone_device *tz, int trip)
                                 (instance->target == THERMAL_NO_TARGET)))
                        continue;
 
-               target = pid_thermal_gov_get_target(tz, instance->cdev,
-                                                   trip_type, trip_temp);
-               if (target >= instance->upper)
+               if (instance->upper == instance->lower) {
                        target = instance->upper;
-               else if (target < instance->lower)
-                       target = instance->lower;
+               } else {
+                       target = pid_thermal_gov_get_target(tz, instance->cdev,
+                                                       trip_type, trip_temp);
+                       target = min(max(target, instance->lower),
+                                    instance->upper);
+               }
 
                if ((tz->temperature < trip_temp) &&
                                (instance->target == instance->lower) &&