aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/thermal/step_wise.c17
-rw-r--r--drivers/thermal/thermal_core.c19
-rw-r--r--drivers/thermal/thermal_core.h1
3 files changed, 33 insertions, 4 deletions
diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
index 2f9f7086ac3d..ea9366ad3e6b 100644
--- a/drivers/thermal/step_wise.c
+++ b/drivers/thermal/step_wise.c
@@ -63,6 +63,19 @@ static unsigned long get_target_state(struct thermal_instance *instance,
63 next_target = instance->target; 63 next_target = instance->target;
64 dev_dbg(&cdev->device, "cur_state=%ld\n", cur_state); 64 dev_dbg(&cdev->device, "cur_state=%ld\n", cur_state);
65 65
66 if (!instance->initialized) {
67 if (throttle) {
68 next_target = (cur_state + 1) >= instance->upper ?
69 instance->upper :
70 ((cur_state + 1) < instance->lower ?
71 instance->lower : (cur_state + 1));
72 } else {
73 next_target = THERMAL_NO_TARGET;
74 }
75
76 return next_target;
77 }
78
66 switch (trend) { 79 switch (trend) {
67 case THERMAL_TREND_RAISING: 80 case THERMAL_TREND_RAISING:
68 if (throttle) { 81 if (throttle) {
@@ -149,7 +162,7 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
149 dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n", 162 dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n",
150 old_target, (int)instance->target); 163 old_target, (int)instance->target);
151 164
152 if (old_target == instance->target) 165 if (instance->initialized && old_target == instance->target)
153 continue; 166 continue;
154 167
155 /* Activate a passive thermal instance */ 168 /* Activate a passive thermal instance */
@@ -161,7 +174,7 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
161 instance->target == THERMAL_NO_TARGET) 174 instance->target == THERMAL_NO_TARGET)
162 update_passive_instance(tz, trip_type, -1); 175 update_passive_instance(tz, trip_type, -1);
163 176
164 177 instance->initialized = true;
165 instance->cdev->updated = false; /* cdev needs update */ 178 instance->cdev->updated = false; /* cdev needs update */
166 } 179 }
167 180
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index d9e525cc9c1c..682bc1ef9c37 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -532,8 +532,22 @@ static void update_temperature(struct thermal_zone_device *tz)
532 mutex_unlock(&tz->lock); 532 mutex_unlock(&tz->lock);
533 533
534 trace_thermal_temperature(tz); 534 trace_thermal_temperature(tz);
535 dev_dbg(&tz->device, "last_temperature=%d, current_temperature=%d\n", 535 if (tz->last_temperature == THERMAL_TEMP_INVALID)
536 tz->last_temperature, tz->temperature); 536 dev_dbg(&tz->device, "last_temperature N/A, current_temperature=%d\n",
537 tz->temperature);
538 else
539 dev_dbg(&tz->device, "last_temperature=%d, current_temperature=%d\n",
540 tz->last_temperature, tz->temperature);
541}
542
543static void thermal_zone_device_reset(struct thermal_zone_device *tz)
544{
545 struct thermal_instance *pos;
546
547 tz->temperature = THERMAL_TEMP_INVALID;
548 tz->passive = 0;
549 list_for_each_entry(pos, &tz->thermal_instances, tz_node)
550 pos->initialized = false;
537} 551}
538 552
539void thermal_zone_device_update(struct thermal_zone_device *tz) 553void thermal_zone_device_update(struct thermal_zone_device *tz)
@@ -1900,6 +1914,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
1900 1914
1901 INIT_DELAYED_WORK(&(tz->poll_queue), thermal_zone_device_check); 1915 INIT_DELAYED_WORK(&(tz->poll_queue), thermal_zone_device_check);
1902 1916
1917 thermal_zone_device_reset(tz);
1903 thermal_zone_device_update(tz); 1918 thermal_zone_device_update(tz);
1904 1919
1905 return tz; 1920 return tz;
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index d7ac1fccd659..749d41abfbab 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -41,6 +41,7 @@ struct thermal_instance {
41 struct thermal_zone_device *tz; 41 struct thermal_zone_device *tz;
42 struct thermal_cooling_device *cdev; 42 struct thermal_cooling_device *cdev;
43 int trip; 43 int trip;
44 bool initialized;
44 unsigned long upper; /* Highest cooling state for this trip point */ 45 unsigned long upper; /* Highest cooling state for this trip point */
45 unsigned long lower; /* Lowest cooling state for this trip point */ 46 unsigned long lower; /* Lowest cooling state for this trip point */
46 unsigned long target; /* expected cooling state */ 47 unsigned long target; /* expected cooling state */