aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-08-25 05:49:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-25 05:49:38 -0400
commit61c04572de404e52a655a36752e696bbcb483cf5 (patch)
tree48e3f1e1594d96910a41815f20653a6a1163282d
parent4935e04ef431c7980ba6e8145ad4c697abccf6b9 (diff)
parent829bc78aa7628e81a9de717316b85cbee3c5eb86 (diff)
Merge branch 'for-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
Pull thermal fixes from Zhang Rui: - Fix cpu_cooling to have separate thermal_cooling_device_ops structures for cpus with and without power model, to avoid NULL dereference in cpufreq_state2power. From Brendan Jackman. - Fix a possible NULL dereference in imx_thermal driver. From Corentin LABBE. - Another two trivial fixes, one typo fix and one deleting module owner. From Caesar Wang and Markus Elfring. * 'for-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux: thermal: imx: fix a possible NULL dereference thermal: trivial: fix the typo Thermal-INT3406: Delete owner assignment thermal: cpu_cooling: Fix NULL dereference in cpufreq_state2power
-rw-r--r--Documentation/devicetree/bindings/thermal/thermal.txt10
-rw-r--r--drivers/thermal/cpu_cooling.c21
-rw-r--r--drivers/thermal/imx_thermal.c4
-rw-r--r--drivers/thermal/int340x_thermal/int3406_thermal.c1
4 files changed, 22 insertions, 14 deletions
diff --git a/Documentation/devicetree/bindings/thermal/thermal.txt b/Documentation/devicetree/bindings/thermal/thermal.txt
index 41b817f7b670..88b6ea1ad290 100644
--- a/Documentation/devicetree/bindings/thermal/thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/thermal.txt
@@ -62,7 +62,7 @@ For more examples of cooling devices, refer to the example sections below.
62Required properties: 62Required properties:
63- #cooling-cells: Used to provide cooling device specific information 63- #cooling-cells: Used to provide cooling device specific information
64 Type: unsigned while referring to it. Must be at least 2, in order 64 Type: unsigned while referring to it. Must be at least 2, in order
65 Size: one cell to specify minimum and maximum cooling state used 65 Size: one cell to specify minimum and maximum cooling state used
66 in the reference. The first cell is the minimum 66 in the reference. The first cell is the minimum
67 cooling state requested and the second cell is 67 cooling state requested and the second cell is
68 the maximum cooling state requested in the reference. 68 the maximum cooling state requested in the reference.
@@ -119,7 +119,7 @@ Required properties:
119Optional property: 119Optional property:
120- contribution: The cooling contribution to the thermal zone of the 120- contribution: The cooling contribution to the thermal zone of the
121 Type: unsigned referred cooling device at the referred trip point. 121 Type: unsigned referred cooling device at the referred trip point.
122 Size: one cell The contribution is a ratio of the sum 122 Size: one cell The contribution is a ratio of the sum
123 of all cooling contributions within a thermal zone. 123 of all cooling contributions within a thermal zone.
124 124
125Note: Using the THERMAL_NO_LIMIT (-1UL) constant in the cooling-device phandle 125Note: Using the THERMAL_NO_LIMIT (-1UL) constant in the cooling-device phandle
@@ -145,7 +145,7 @@ Required properties:
145 Size: one cell 145 Size: one cell
146 146
147- thermal-sensors: A list of thermal sensor phandles and sensor specifier 147- thermal-sensors: A list of thermal sensor phandles and sensor specifier
148 Type: list of used while monitoring the thermal zone. 148 Type: list of used while monitoring the thermal zone.
149 phandles + sensor 149 phandles + sensor
150 specifier 150 specifier
151 151
@@ -473,7 +473,7 @@ thermal-zones {
473 <&adc>; /* pcb north */ 473 <&adc>; /* pcb north */
474 474
475 /* hotspot = 100 * bandgap - 120 * adc + 484 */ 475 /* hotspot = 100 * bandgap - 120 * adc + 484 */
476 coefficients = <100 -120 484>; 476 coefficients = <100 -120 484>;
477 477
478 trips { 478 trips {
479 ... 479 ...
@@ -502,7 +502,7 @@ from the ADC sensor. The binding would be then:
502 thermal-sensors = <&adc>; 502 thermal-sensors = <&adc>;
503 503
504 /* hotspot = 1 * adc + 6000 */ 504 /* hotspot = 1 * adc + 6000 */
505 coefficients = <1 6000>; 505 coefficients = <1 6000>;
506 506
507(d) - Board thermal 507(d) - Board thermal
508 508
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
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index c5547bd711db..e473548b5d28 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -471,8 +471,6 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
471 471
472static int imx_thermal_probe(struct platform_device *pdev) 472static int imx_thermal_probe(struct platform_device *pdev)
473{ 473{
474 const struct of_device_id *of_id =
475 of_match_device(of_imx_thermal_match, &pdev->dev);
476 struct imx_thermal_data *data; 474 struct imx_thermal_data *data;
477 struct regmap *map; 475 struct regmap *map;
478 int measure_freq; 476 int measure_freq;
@@ -490,7 +488,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
490 } 488 }
491 data->tempmon = map; 489 data->tempmon = map;
492 490
493 data->socdata = of_id->data; 491 data->socdata = of_device_get_match_data(&pdev->dev);
494 492
495 /* make sure the IRQ flag is clear before enabling irq on i.MX6SX */ 493 /* make sure the IRQ flag is clear before enabling irq on i.MX6SX */
496 if (data->socdata->version == TEMPMON_IMX6SX) { 494 if (data->socdata->version == TEMPMON_IMX6SX) {
diff --git a/drivers/thermal/int340x_thermal/int3406_thermal.c b/drivers/thermal/int340x_thermal/int3406_thermal.c
index a578cd257db4..1891f34ab7fc 100644
--- a/drivers/thermal/int340x_thermal/int3406_thermal.c
+++ b/drivers/thermal/int340x_thermal/int3406_thermal.c
@@ -225,7 +225,6 @@ static struct platform_driver int3406_thermal_driver = {
225 .remove = int3406_thermal_remove, 225 .remove = int3406_thermal_remove,
226 .driver = { 226 .driver = {
227 .name = "int3406 thermal", 227 .name = "int3406 thermal",
228 .owner = THIS_MODULE,
229 .acpi_match_table = int3406_thermal_match, 228 .acpi_match_table = int3406_thermal_match,
230 }, 229 },
231}; 230};