aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal/step_wise.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/thermal/step_wise.c')
-rw-r--r--drivers/thermal/step_wise.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
index 407cde3211c1..4d4ddae1a991 100644
--- a/drivers/thermal/step_wise.c
+++ b/drivers/thermal/step_wise.c
@@ -22,9 +22,6 @@
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */ 23 */
24 24
25#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26
27#include <linux/module.h>
28#include <linux/thermal.h> 25#include <linux/thermal.h>
29 26
30#include "thermal_core.h" 27#include "thermal_core.h"
@@ -59,9 +56,12 @@ static unsigned long get_target_state(struct thermal_instance *instance,
59 56
60 switch (trend) { 57 switch (trend) {
61 case THERMAL_TREND_RAISING: 58 case THERMAL_TREND_RAISING:
62 if (throttle) 59 if (throttle) {
63 cur_state = cur_state < instance->upper ? 60 cur_state = cur_state < instance->upper ?
64 (cur_state + 1) : instance->upper; 61 (cur_state + 1) : instance->upper;
62 if (cur_state < instance->lower)
63 cur_state = instance->lower;
64 }
65 break; 65 break;
66 case THERMAL_TREND_RAISE_FULL: 66 case THERMAL_TREND_RAISE_FULL:
67 if (throttle) 67 if (throttle)
@@ -71,8 +71,11 @@ static unsigned long get_target_state(struct thermal_instance *instance,
71 if (cur_state == instance->lower) { 71 if (cur_state == instance->lower) {
72 if (!throttle) 72 if (!throttle)
73 cur_state = -1; 73 cur_state = -1;
74 } else 74 } else {
75 cur_state -= 1; 75 cur_state -= 1;
76 if (cur_state > instance->upper)
77 cur_state = instance->upper;
78 }
76 break; 79 break;
77 case THERMAL_TREND_DROP_FULL: 80 case THERMAL_TREND_DROP_FULL:
78 if (cur_state == instance->lower) { 81 if (cur_state == instance->lower) {
@@ -180,23 +183,14 @@ static int step_wise_throttle(struct thermal_zone_device *tz, int trip)
180static struct thermal_governor thermal_gov_step_wise = { 183static struct thermal_governor thermal_gov_step_wise = {
181 .name = "step_wise", 184 .name = "step_wise",
182 .throttle = step_wise_throttle, 185 .throttle = step_wise_throttle,
183 .owner = THIS_MODULE,
184}; 186};
185 187
186static int __init thermal_gov_step_wise_init(void) 188int thermal_gov_step_wise_register(void)
187{ 189{
188 return thermal_register_governor(&thermal_gov_step_wise); 190 return thermal_register_governor(&thermal_gov_step_wise);
189} 191}
190 192
191static void __exit thermal_gov_step_wise_exit(void) 193void thermal_gov_step_wise_unregister(void)
192{ 194{
193 thermal_unregister_governor(&thermal_gov_step_wise); 195 thermal_unregister_governor(&thermal_gov_step_wise);
194} 196}
195
196/* This should load after thermal framework */
197fs_initcall(thermal_gov_step_wise_init);
198module_exit(thermal_gov_step_wise_exit);
199
200MODULE_AUTHOR("Durgadoss R");
201MODULE_DESCRIPTION("A step-by-step thermal throttling governor");
202MODULE_LICENSE("GPL");