aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal/cpu_cooling.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-06-13 17:33:17 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-06-13 17:33:17 -0400
commitbb4b9933e2bc0554cf4db37aa07b19ff69a85f8f (patch)
tree92ec230e0292874d6a53ff33534e8637fa315479 /drivers/thermal/cpu_cooling.c
parent5edb56491d4812c42175980759da53388e5d86f5 (diff)
parentf6709b8aa78fb6765c443ad6b70fdaf48b89d95d (diff)
Merge back earlier cpufreq changes for v4.8.
Diffstat (limited to 'drivers/thermal/cpu_cooling.c')
-rw-r--r--drivers/thermal/cpu_cooling.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 5b4b47ed948b..3788ed74c9ab 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -787,22 +787,34 @@ __cpufreq_cooling_register(struct device_node *np,
787 const struct cpumask *clip_cpus, u32 capacitance, 787 const struct cpumask *clip_cpus, u32 capacitance,
788 get_static_t plat_static_func) 788 get_static_t plat_static_func)
789{ 789{
790 struct cpufreq_policy *policy;
790 struct thermal_cooling_device *cool_dev; 791 struct thermal_cooling_device *cool_dev;
791 struct cpufreq_cooling_device *cpufreq_dev; 792 struct cpufreq_cooling_device *cpufreq_dev;
792 char dev_name[THERMAL_NAME_LENGTH]; 793 char dev_name[THERMAL_NAME_LENGTH];
793 struct cpufreq_frequency_table *pos, *table; 794 struct cpufreq_frequency_table *pos, *table;
795 struct cpumask temp_mask;
794 unsigned int freq, i, num_cpus; 796 unsigned int freq, i, num_cpus;
795 int ret; 797 int ret;
796 798
797 table = cpufreq_frequency_get_table(cpumask_first(clip_cpus)); 799 cpumask_and(&temp_mask, clip_cpus, cpu_online_mask);
800 policy = cpufreq_cpu_get(cpumask_first(&temp_mask));
801 if (!policy) {
802 pr_debug("%s: CPUFreq policy not found\n", __func__);
803 return ERR_PTR(-EPROBE_DEFER);
804 }
805
806 table = policy->freq_table;
798 if (!table) { 807 if (!table) {
799 pr_debug("%s: CPUFreq table not found\n", __func__); 808 pr_debug("%s: CPUFreq table not found\n", __func__);
800 return ERR_PTR(-EPROBE_DEFER); 809 cool_dev = ERR_PTR(-ENODEV);
810 goto put_policy;
801 } 811 }
802 812
803 cpufreq_dev = kzalloc(sizeof(*cpufreq_dev), GFP_KERNEL); 813 cpufreq_dev = kzalloc(sizeof(*cpufreq_dev), GFP_KERNEL);
804 if (!cpufreq_dev) 814 if (!cpufreq_dev) {
805 return ERR_PTR(-ENOMEM); 815 cool_dev = ERR_PTR(-ENOMEM);
816 goto put_policy;
817 }
806 818
807 num_cpus = cpumask_weight(clip_cpus); 819 num_cpus = cpumask_weight(clip_cpus);
808 cpufreq_dev->time_in_idle = kcalloc(num_cpus, 820 cpufreq_dev->time_in_idle = kcalloc(num_cpus,
@@ -892,7 +904,7 @@ __cpufreq_cooling_register(struct device_node *np,
892 CPUFREQ_POLICY_NOTIFIER); 904 CPUFREQ_POLICY_NOTIFIER);
893 mutex_unlock(&cooling_cpufreq_lock); 905 mutex_unlock(&cooling_cpufreq_lock);
894 906
895 return cool_dev; 907 goto put_policy;
896 908
897remove_idr: 909remove_idr:
898 release_idr(&cpufreq_idr, cpufreq_dev->id); 910 release_idr(&cpufreq_idr, cpufreq_dev->id);
@@ -906,6 +918,8 @@ free_time_in_idle:
906 kfree(cpufreq_dev->time_in_idle); 918 kfree(cpufreq_dev->time_in_idle);
907free_cdev: 919free_cdev:
908 kfree(cpufreq_dev); 920 kfree(cpufreq_dev);
921put_policy:
922 cpufreq_cpu_put(policy);
909 923
910 return cool_dev; 924 return cool_dev;
911} 925}