diff options
author | Zhang Rui <rui.zhang@intel.com> | 2013-02-08 01:52:06 -0500 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2013-03-26 02:33:50 -0400 |
commit | 57df8106932b57427df1eaaa13871857f75b1194 (patch) | |
tree | 031702338779869067dde6be83aedeee9e8d6e2b | |
parent | fc35b35cbe24ef021ea9acfba21e54da958df747 (diff) |
Thermal: exynos: fix cooling state translation
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Tested-by: Amit Daniel kachhap <amit.daniel@samsung.com>
-rw-r--r-- | drivers/thermal/cpu_cooling.c | 11 | ||||
-rw-r--r-- | drivers/thermal/exynos_thermal.c | 24 | ||||
-rw-r--r-- | include/linux/cpu_cooling.h | 7 | ||||
-rw-r--r-- | include/linux/thermal.h | 5 |
4 files changed, 24 insertions, 23 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 9e208d300647..e03891b03c9b 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c | |||
@@ -196,6 +196,17 @@ static int get_property(unsigned int cpu, unsigned long input, | |||
196 | return -EINVAL; | 196 | return -EINVAL; |
197 | } | 197 | } |
198 | 198 | ||
199 | unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) | ||
200 | { | ||
201 | unsigned int val; | ||
202 | |||
203 | if (get_property(cpu, (unsigned long)freq, &val, GET_LEVEL)) | ||
204 | return THERMAL_CSTATE_INVALID; | ||
205 | return (unsigned long)val; | ||
206 | } | ||
207 | |||
208 | EXPORT_SYMBOL(cpufreq_cooling_get_level); | ||
209 | |||
199 | /** | 210 | /** |
200 | * get_cpu_frequency - get the absolute value of frequency from level. | 211 | * get_cpu_frequency - get the absolute value of frequency from level. |
201 | * @cpu: cpu for which frequency is fetched. | 212 | * @cpu: cpu for which frequency is fetched. |
diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 46568c078dee..541257888c3e 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c | |||
@@ -242,26 +242,6 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal, | |||
242 | return ret; | 242 | return ret; |
243 | } | 243 | } |
244 | 244 | ||
245 | static int exynos_get_frequency_level(unsigned int cpu, unsigned int freq) | ||
246 | { | ||
247 | int i = 0, ret = -EINVAL; | ||
248 | struct cpufreq_frequency_table *table = NULL; | ||
249 | #ifdef CONFIG_CPU_FREQ | ||
250 | table = cpufreq_frequency_get_table(cpu); | ||
251 | #endif | ||
252 | if (!table) | ||
253 | return ret; | ||
254 | |||
255 | while (table[i].frequency != CPUFREQ_TABLE_END) { | ||
256 | if (table[i].frequency == CPUFREQ_ENTRY_INVALID) | ||
257 | continue; | ||
258 | if (table[i].frequency == freq) | ||
259 | return i; | ||
260 | i++; | ||
261 | } | ||
262 | return ret; | ||
263 | } | ||
264 | |||
265 | /* Bind callback functions for thermal zone */ | 245 | /* Bind callback functions for thermal zone */ |
266 | static int exynos_bind(struct thermal_zone_device *thermal, | 246 | static int exynos_bind(struct thermal_zone_device *thermal, |
267 | struct thermal_cooling_device *cdev) | 247 | struct thermal_cooling_device *cdev) |
@@ -288,8 +268,8 @@ static int exynos_bind(struct thermal_zone_device *thermal, | |||
288 | /* Bind the thermal zone to the cpufreq cooling device */ | 268 | /* Bind the thermal zone to the cpufreq cooling device */ |
289 | for (i = 0; i < tab_size; i++) { | 269 | for (i = 0; i < tab_size; i++) { |
290 | clip_data = (struct freq_clip_table *)&(tab_ptr[i]); | 270 | clip_data = (struct freq_clip_table *)&(tab_ptr[i]); |
291 | level = exynos_get_frequency_level(0, clip_data->freq_clip_max); | 271 | level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max); |
292 | if (level < 0) | 272 | if (level == THERMAL_CSTATE_INVALID) |
293 | return 0; | 273 | return 0; |
294 | switch (GET_ZONE(i)) { | 274 | switch (GET_ZONE(i)) { |
295 | case MONITOR_ZONE: | 275 | case MONITOR_ZONE: |
diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h index 40b4ef54cc7d..bc479b1e0fd9 100644 --- a/include/linux/cpu_cooling.h +++ b/include/linux/cpu_cooling.h | |||
@@ -42,6 +42,8 @@ struct thermal_cooling_device *cpufreq_cooling_register( | |||
42 | * @cdev: thermal cooling device pointer. | 42 | * @cdev: thermal cooling device pointer. |
43 | */ | 43 | */ |
44 | void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev); | 44 | void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev); |
45 | |||
46 | unsigned long cpufreq_cooling_get_level(unsigned int, unsigned int); | ||
45 | #else /* !CONFIG_CPU_THERMAL */ | 47 | #else /* !CONFIG_CPU_THERMAL */ |
46 | static inline struct thermal_cooling_device *cpufreq_cooling_register( | 48 | static inline struct thermal_cooling_device *cpufreq_cooling_register( |
47 | const struct cpumask *clip_cpus) | 49 | const struct cpumask *clip_cpus) |
@@ -53,6 +55,11 @@ static inline void cpufreq_cooling_unregister( | |||
53 | { | 55 | { |
54 | return; | 56 | return; |
55 | } | 57 | } |
58 | static inline unsigned long cpufreq_cooling_get_level(unsigned int, | ||
59 | unsigned int) | ||
60 | { | ||
61 | return THERMAL_CSTATE_INVALID; | ||
62 | } | ||
56 | #endif /* CONFIG_CPU_THERMAL */ | 63 | #endif /* CONFIG_CPU_THERMAL */ |
57 | 64 | ||
58 | #endif /* __CPU_COOLING_H__ */ | 65 | #endif /* __CPU_COOLING_H__ */ |
diff --git a/include/linux/thermal.h b/include/linux/thermal.h index f0bd7f90a90d..5a3b428daaab 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h | |||
@@ -33,8 +33,11 @@ | |||
33 | #define THERMAL_MAX_TRIPS 12 | 33 | #define THERMAL_MAX_TRIPS 12 |
34 | #define THERMAL_NAME_LENGTH 20 | 34 | #define THERMAL_NAME_LENGTH 20 |
35 | 35 | ||
36 | /* invalid cooling state */ | ||
37 | #define THERMAL_CSTATE_INVALID -1UL | ||
38 | |||
36 | /* No upper/lower limit requirement */ | 39 | /* No upper/lower limit requirement */ |
37 | #define THERMAL_NO_LIMIT -1UL | 40 | #define THERMAL_NO_LIMIT THERMAL_CSTATE_INVALID |
38 | 41 | ||
39 | /* Unit conversion macros */ | 42 | /* Unit conversion macros */ |
40 | #define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732 >= 0) ? \ | 43 | #define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732 >= 0) ? \ |