aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal/cpu_cooling.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/thermal/cpu_cooling.c')
-rw-r--r--drivers/thermal/cpu_cooling.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 3788ed74c9ab..a32b41783b77 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -740,12 +740,22 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev,
740} 740}
741 741
742/* Bind cpufreq callbacks to thermal cooling device ops */ 742/* Bind cpufreq callbacks to thermal cooling device ops */
743
743static struct thermal_cooling_device_ops cpufreq_cooling_ops = { 744static struct thermal_cooling_device_ops cpufreq_cooling_ops = {
744 .get_max_state = cpufreq_get_max_state, 745 .get_max_state = cpufreq_get_max_state,
745 .get_cur_state = cpufreq_get_cur_state, 746 .get_cur_state = cpufreq_get_cur_state,
746 .set_cur_state = cpufreq_set_cur_state, 747 .set_cur_state = cpufreq_set_cur_state,
747}; 748};
748 749
750static struct thermal_cooling_device_ops cpufreq_power_cooling_ops = {
751 .get_max_state = cpufreq_get_max_state,
752 .get_cur_state = cpufreq_get_cur_state,
753 .set_cur_state = cpufreq_set_cur_state,
754 .get_requested_power = cpufreq_get_requested_power,
755 .state2power = cpufreq_state2power,
756 .power2state = cpufreq_power2state,
757};
758
749/* Notifier for cpufreq policy change */ 759/* Notifier for cpufreq policy change */
750static struct notifier_block thermal_cpufreq_notifier_block = { 760static struct notifier_block thermal_cpufreq_notifier_block = {
751 .notifier_call = cpufreq_thermal_notifier, 761 .notifier_call = cpufreq_thermal_notifier,
@@ -795,6 +805,7 @@ __cpufreq_cooling_register(struct device_node *np,
795 struct cpumask temp_mask; 805 struct cpumask temp_mask;
796 unsigned int freq, i, num_cpus; 806 unsigned int freq, i, num_cpus;
797 int ret; 807 int ret;
808 struct thermal_cooling_device_ops *cooling_ops;
798 809
799 cpumask_and(&temp_mask, clip_cpus, cpu_online_mask); 810 cpumask_and(&temp_mask, clip_cpus, cpu_online_mask);
800 policy = cpufreq_cpu_get(cpumask_first(&temp_mask)); 811 policy = cpufreq_cpu_get(cpumask_first(&temp_mask));
@@ -850,10 +861,6 @@ __cpufreq_cooling_register(struct device_node *np,
850 cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus); 861 cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus);
851 862
852 if (capacitance) { 863 if (capacitance) {
853 cpufreq_cooling_ops.get_requested_power =
854 cpufreq_get_requested_power;
855 cpufreq_cooling_ops.state2power = cpufreq_state2power;
856 cpufreq_cooling_ops.power2state = cpufreq_power2state;
857 cpufreq_dev->plat_get_static_power = plat_static_func; 864 cpufreq_dev->plat_get_static_power = plat_static_func;
858 865
859 ret = build_dyn_power_table(cpufreq_dev, capacitance); 866 ret = build_dyn_power_table(cpufreq_dev, capacitance);
@@ -861,6 +868,10 @@ __cpufreq_cooling_register(struct device_node *np,
861 cool_dev = ERR_PTR(ret); 868 cool_dev = ERR_PTR(ret);
862 goto free_table; 869 goto free_table;
863 } 870 }
871
872 cooling_ops = &cpufreq_power_cooling_ops;
873 } else {
874 cooling_ops = &cpufreq_cooling_ops;
864 } 875 }
865 876
866 ret = get_idr(&cpufreq_idr, &cpufreq_dev->id); 877 ret = get_idr(&cpufreq_idr, &cpufreq_dev->id);
@@ -885,7 +896,7 @@ __cpufreq_cooling_register(struct device_node *np,
885 cpufreq_dev->id); 896 cpufreq_dev->id);
886 897
887 cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev, 898 cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev,
888 &cpufreq_cooling_ops); 899 cooling_ops);
889 if (IS_ERR(cool_dev)) 900 if (IS_ERR(cool_dev))
890 goto remove_idr; 901 goto remove_idr;
891 902