misc: nct1008: Apply hysteresis to only PASSIVE trip_points
Diwakar Tundlam [Thu, 31 Jan 2013 23:37:44 +0000 (15:37 -0800)]
Applying hysteresis to ACTIVE trip point messes up EDP limiting.

Bug 1200202

Change-Id: Id723f2c2d094d7e1e72cee208b54afed64175c2a
Signed-off-by: Diwakar Tundlam <dtundlam@nvidia.com>
Reviewed-on: http://git-master/r/196193
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Matthew Longnecker <mlongnecker@nvidia.com>
Reviewed-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-by: Aleksandr Frid <afrid@nvidia.com>
GVS: Gerrit_Virtual_Submit

drivers/misc/nct1008.c

index 68be49a..eb3add5 100644 (file)
@@ -499,8 +499,10 @@ static void nct1008_update(struct nct1008_data *data)
        for (count = 0; count < thz->trips; count++) {
                trip_state = &data->plat_data.trips[count];
                trip_temp = trip_state->trip_temp;
-               hysteresis_temp = trip_state->tripped ?
-                               trip_temp - trip_state->hysteresis : trip_temp;
+               hysteresis_temp = trip_temp - trip_state->hysteresis;
+               if ((trip_state->trip_type == THERMAL_TRIP_PASSIVE) &&
+                   !trip_state->tripped)
+                       hysteresis_temp = trip_temp;
 
                if ((trip_temp >= temp) && (trip_temp < high_temp)) {
                        high_temp = trip_temp;
@@ -591,7 +593,10 @@ static int nct1008_ext_get_trip_temp(struct thermal_zone_device *thz,
 
        *temp = trip_state->trip_temp;
 
-       if (thz->temperature >= trip_state->trip_temp) {
+       if (trip_state->trip_type != THERMAL_TRIP_PASSIVE)
+               return 0;
+
+       if (thz->temperature >= *temp) {
                trip_state->tripped = true;
        } else if (trip_state->tripped) {
                *temp -= trip_state->hysteresis;