diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 2ab31e4f02cc741ee5d7b1c603a9158b34f335c4..dc4044b682a1afa9c586ba70c03ef74f4e29eb1e 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -1059,6 +1059,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz) enum thermal_trip_type trip_type; struct thermal_cooling_device_instance *instance; struct thermal_cooling_device *cdev; + unsigned long cur_state, max_state; mutex_lock(&tz->lock); @@ -1098,10 +1099,17 @@ void thermal_zone_device_update(struct thermal_zone_device *tz) cdev = instance->cdev; + cdev->ops->get_cur_state(cdev, &cur_state); + cdev->ops->get_max_state(cdev, &max_state); + if (temp >= trip_temp) - cdev->ops->set_cur_state(cdev, 1); + cur_state = cur_state < max_state ? + (cur_state + 1) : max_state; else - cdev->ops->set_cur_state(cdev, 0); + cur_state = cur_state > 0 ? + (cur_state - 1) : 0; + + cdev->ops->set_cur_state(cdev, cur_state); } break; case THERMAL_TRIP_PASSIVE: