aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal/step_wise.c
diff options
context:
space:
mode:
authorAndrew Bresticker <abrestic@chromium.org>2013-04-09 21:59:47 +0000
committerZhang Rui <rui.zhang@intel.com>2013-04-12 07:23:50 +0800
commite79fe642cc21ac922226b5ea9b7975bf329d4e7a (patch)
tree67236d2b6ff05132b7fc6ae74b66c3f8b34ce3dc /drivers/thermal/step_wise.c
parent8837295a73f3500b32e18f9862c7bdde0b958648 (diff)
downloadkernel_goldelico_gta04-e79fe642cc21ac922226b5ea9b7975bf329d4e7a.zip
kernel_goldelico_gta04-e79fe642cc21ac922226b5ea9b7975bf329d4e7a.tar.gz
kernel_goldelico_gta04-e79fe642cc21ac922226b5ea9b7975bf329d4e7a.tar.bz2
thermal: step_wise: set throttle target within thermal instance limits
When selecting a target cooling state in get_target_state(), make sure that the state is at least as high as the minimum when the temperature is rising and at least as low as the maximum when the temperature is falling. This is necessary because, in the THREAML_TREND_RAISING and THERMAL_TREND_DROPPING cases, the current state may only be incremented or decremented by one even if it is outside the bounds of the thermal instance. This might occur, for example, if the CPU is heating up and hits a thermal trip point for the first time when it's frequency is much higher than the range specified by the thermal instance corresponding to the trip point. Signed-off-by: Andrew Bresticker <abrestic@chromium.org> Acked-by: Eduardo Valentin <eduardo.valentin@ti.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal/step_wise.c')
-rw-r--r--drivers/thermal/step_wise.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
index 407cde3..ca4f79f 100644
--- a/drivers/thermal/step_wise.c
+++ b/drivers/thermal/step_wise.c
@@ -59,9 +59,12 @@ static unsigned long get_target_state(struct thermal_instance *instance,
switch (trend) {
case THERMAL_TREND_RAISING:
- if (throttle)
+ if (throttle) {
cur_state = cur_state < instance->upper ?
(cur_state + 1) : instance->upper;
+ if (cur_state < instance->lower)
+ cur_state = instance->lower;
+ }
break;
case THERMAL_TREND_RAISE_FULL:
if (throttle)
@@ -71,8 +74,11 @@ static unsigned long get_target_state(struct thermal_instance *instance,
if (cur_state == instance->lower) {
if (!throttle)
cur_state = -1;
- } else
+ } else {
cur_state -= 1;
+ if (cur_state > instance->upper)
+ cur_state = instance->upper;
+ }
break;
case THERMAL_TREND_DROP_FULL:
if (cur_state == instance->lower) {