diff options
Diffstat (limited to 'drivers/thermal/cpu_cooling.c')
-rw-r--r-- | drivers/thermal/cpu_cooling.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index f7c1f49ec87f..4c5db59a619b 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c | |||
@@ -1,26 +1,14 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * linux/drivers/thermal/cpu_cooling.c | 3 | * linux/drivers/thermal/cpu_cooling.c |
3 | * | 4 | * |
4 | * Copyright (C) 2012 Samsung Electronics Co., Ltd(http://www.samsung.com) | 5 | * Copyright (C) 2012 Samsung Electronics Co., Ltd(http://www.samsung.com) |
5 | * Copyright (C) 2012 Amit Daniel <amit.kachhap@linaro.org> | ||
6 | * | 6 | * |
7 | * Copyright (C) 2014 Viresh Kumar <viresh.kumar@linaro.org> | 7 | * Copyright (C) 2012-2018 Linaro Limited. |
8 | * | 8 | * |
9 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 9 | * Authors: Amit Daniel <amit.kachhap@linaro.org> |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * Viresh Kumar <viresh.kumar@linaro.org> |
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; version 2 of the License. | ||
13 | * | 11 | * |
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
21 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | * | ||
23 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
24 | */ | 12 | */ |
25 | #include <linux/module.h> | 13 | #include <linux/module.h> |
26 | #include <linux/thermal.h> | 14 | #include <linux/thermal.h> |
@@ -99,7 +87,6 @@ struct cpufreq_cooling_device { | |||
99 | unsigned int clipped_freq; | 87 | unsigned int clipped_freq; |
100 | unsigned int max_level; | 88 | unsigned int max_level; |
101 | struct freq_table *freq_table; /* In descending order */ | 89 | struct freq_table *freq_table; /* In descending order */ |
102 | struct thermal_cooling_device *cdev; | ||
103 | struct cpufreq_policy *policy; | 90 | struct cpufreq_policy *policy; |
104 | struct list_head node; | 91 | struct list_head node; |
105 | struct time_in_idle *idle_time; | 92 | struct time_in_idle *idle_time; |
@@ -207,8 +194,7 @@ static int update_freq_table(struct cpufreq_cooling_device *cpufreq_cdev, | |||
207 | 194 | ||
208 | dev = get_cpu_device(cpu); | 195 | dev = get_cpu_device(cpu); |
209 | if (unlikely(!dev)) { | 196 | if (unlikely(!dev)) { |
210 | dev_warn(&cpufreq_cdev->cdev->device, | 197 | pr_warn("No cpu device for cpu %d\n", cpu); |
211 | "No cpu device for cpu %d\n", cpu); | ||
212 | return -ENODEV; | 198 | return -ENODEV; |
213 | } | 199 | } |
214 | 200 | ||
@@ -458,7 +444,7 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev, | |||
458 | load = 0; | 444 | load = 0; |
459 | 445 | ||
460 | total_load += load; | 446 | total_load += load; |
461 | if (trace_thermal_power_cpu_limit_enabled() && load_cpu) | 447 | if (load_cpu) |
462 | load_cpu[i] = load; | 448 | load_cpu[i] = load; |
463 | 449 | ||
464 | i++; | 450 | i++; |
@@ -541,7 +527,6 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, | |||
541 | struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; | 527 | struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; |
542 | struct cpufreq_policy *policy = cpufreq_cdev->policy; | 528 | struct cpufreq_policy *policy = cpufreq_cdev->policy; |
543 | 529 | ||
544 | power = power > 0 ? power : 0; | ||
545 | last_load = cpufreq_cdev->last_load ?: 1; | 530 | last_load = cpufreq_cdev->last_load ?: 1; |
546 | normalised_power = (power * 100) / last_load; | 531 | normalised_power = (power * 100) / last_load; |
547 | target_freq = cpu_power_to_freq(cpufreq_cdev, normalised_power); | 532 | target_freq = cpu_power_to_freq(cpufreq_cdev, normalised_power); |
@@ -692,7 +677,6 @@ __cpufreq_cooling_register(struct device_node *np, | |||
692 | goto remove_ida; | 677 | goto remove_ida; |
693 | 678 | ||
694 | cpufreq_cdev->clipped_freq = cpufreq_cdev->freq_table[0].frequency; | 679 | cpufreq_cdev->clipped_freq = cpufreq_cdev->freq_table[0].frequency; |
695 | cpufreq_cdev->cdev = cdev; | ||
696 | 680 | ||
697 | mutex_lock(&cooling_list_lock); | 681 | mutex_lock(&cooling_list_lock); |
698 | /* Register the notifier for first cpufreq cooling device */ | 682 | /* Register the notifier for first cpufreq cooling device */ |
@@ -810,7 +794,7 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) | |||
810 | cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, | 794 | cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, |
811 | CPUFREQ_POLICY_NOTIFIER); | 795 | CPUFREQ_POLICY_NOTIFIER); |
812 | 796 | ||
813 | thermal_cooling_device_unregister(cpufreq_cdev->cdev); | 797 | thermal_cooling_device_unregister(cdev); |
814 | ida_simple_remove(&cpufreq_ida, cpufreq_cdev->id); | 798 | ida_simple_remove(&cpufreq_ida, cpufreq_cdev->id); |
815 | kfree(cpufreq_cdev->idle_time); | 799 | kfree(cpufreq_cdev->idle_time); |
816 | kfree(cpufreq_cdev->freq_table); | 800 | kfree(cpufreq_cdev->freq_table); |