kernel/4.3: update to version 4.3.3
[openwrt/openwrt.git] / target / linux / mediatek / patches / 0010-thermal-consistently-use-int-for-temperatures.patch
1 From 29e6031548373b9e7ec0c17e85da6a4cf4fee7f5 Mon Sep 17 00:00:00 2001
2 From: Sascha Hauer <s.hauer@pengutronix.de>
3 Date: Wed, 13 May 2015 10:52:29 +0200
4 Subject: [PATCH 10/76] thermal: consistently use int for temperatures
5
6 The thermal code uses int, long and unsigned long for temperatures
7 in different places. Using an unsigned type limits the thermal framework
8 to positive temperatures without need. 'long' is 64bit on several
9 architectures which is not needed. Consistently use a plain 'int'
10 for temperatures.
11
12 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
13 ---
14 drivers/acpi/thermal.c | 12 ++++-----
15 drivers/hwmon/lm75.c | 2 +-
16 drivers/hwmon/ntc_thermistor.c | 2 +-
17 drivers/hwmon/tmp102.c | 2 +-
18 drivers/input/touchscreen/sun4i-ts.c | 8 +++---
19 drivers/platform/x86/acerhdf.c | 9 +++----
20 drivers/power/power_supply_core.c | 2 +-
21 drivers/thermal/armada_thermal.c | 2 +-
22 drivers/thermal/db8500_thermal.c | 7 +++--
23 drivers/thermal/dove_thermal.c | 2 +-
24 drivers/thermal/fair_share.c | 2 +-
25 drivers/thermal/gov_bang_bang.c | 5 ++--
26 drivers/thermal/imx_thermal.c | 27 ++++++++++----------
27 .../thermal/int340x_thermal/int340x_thermal_zone.c | 10 ++++----
28 .../thermal/int340x_thermal/int340x_thermal_zone.h | 8 +++---
29 drivers/thermal/intel_soc_dts_thermal.c | 7 +++--
30 drivers/thermal/of-thermal.c | 14 +++++-----
31 drivers/thermal/rcar_thermal.c | 7 +++--
32 drivers/thermal/rockchip_thermal.c | 10 ++++----
33 drivers/thermal/samsung/exynos_tmu.c | 19 +++++++-------
34 drivers/thermal/spear_thermal.c | 2 +-
35 drivers/thermal/st/st_thermal.c | 5 ++--
36 drivers/thermal/step_wise.c | 4 +--
37 drivers/thermal/tegra_soctherm.c | 4 +--
38 drivers/thermal/thermal_core.c | 26 +++++++++----------
39 drivers/thermal/thermal_hwmon.c | 10 ++++----
40 drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 10 ++++----
41 drivers/thermal/x86_pkg_temp_thermal.c | 10 ++++----
42 include/linux/thermal.h | 26 ++++++++-----------
43 29 files changed, 120 insertions(+), 134 deletions(-)
44
45 --- a/drivers/acpi/thermal.c
46 +++ b/drivers/acpi/thermal.c
47 @@ -529,8 +529,7 @@ static void acpi_thermal_check(void *dat
48
49 /* sys I/F for generic thermal sysfs support */
50
51 -static int thermal_get_temp(struct thermal_zone_device *thermal,
52 - unsigned long *temp)
53 +static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp)
54 {
55 struct acpi_thermal *tz = thermal->devdata;
56 int result;
57 @@ -637,7 +636,7 @@ static int thermal_get_trip_type(struct
58 }
59
60 static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
61 - int trip, unsigned long *temp)
62 + int trip, int *temp)
63 {
64 struct acpi_thermal *tz = thermal->devdata;
65 int i;
66 @@ -690,7 +689,8 @@ static int thermal_get_trip_temp(struct
67 }
68
69 static int thermal_get_crit_temp(struct thermal_zone_device *thermal,
70 - unsigned long *temperature) {
71 + int *temperature)
72 +{
73 struct acpi_thermal *tz = thermal->devdata;
74
75 if (tz->trips.critical.flags.valid) {
76 @@ -713,8 +713,8 @@ static int thermal_get_trend(struct ther
77 return -EINVAL;
78
79 if (type == THERMAL_TRIP_ACTIVE) {
80 - unsigned long trip_temp;
81 - unsigned long temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(
82 + int trip_temp;
83 + int temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(
84 tz->temperature, tz->kelvin_offset);
85 if (thermal_get_trip_temp(thermal, trip, &trip_temp))
86 return -EINVAL;
87 --- a/drivers/hwmon/lm75.c
88 +++ b/drivers/hwmon/lm75.c
89 @@ -104,7 +104,7 @@ static inline long lm75_reg_to_mc(s16 te
90
91 /* sysfs attributes for hwmon */
92
93 -static int lm75_read_temp(void *dev, long *temp)
94 +static int lm75_read_temp(void *dev, int *temp)
95 {
96 struct lm75_data *data = lm75_update_device(dev);
97
98 --- a/drivers/hwmon/ntc_thermistor.c
99 +++ b/drivers/hwmon/ntc_thermistor.c
100 @@ -439,7 +439,7 @@ static int ntc_thermistor_get_ohm(struct
101 return -EINVAL;
102 }
103
104 -static int ntc_read_temp(void *dev, long *temp)
105 +static int ntc_read_temp(void *dev, int *temp)
106 {
107 struct ntc_data *data = dev_get_drvdata(dev);
108 int ohm;
109 --- a/drivers/hwmon/tmp102.c
110 +++ b/drivers/hwmon/tmp102.c
111 @@ -98,7 +98,7 @@ static struct tmp102 *tmp102_update_devi
112 return tmp102;
113 }
114
115 -static int tmp102_read_temp(void *dev, long *temp)
116 +static int tmp102_read_temp(void *dev, int *temp)
117 {
118 struct tmp102 *tmp102 = tmp102_update_device(dev);
119
120 --- a/drivers/input/touchscreen/sun4i-ts.c
121 +++ b/drivers/input/touchscreen/sun4i-ts.c
122 @@ -191,7 +191,7 @@ static void sun4i_ts_close(struct input_
123 writel(TEMP_IRQ_EN(1), ts->base + TP_INT_FIFOC);
124 }
125
126 -static int sun4i_get_temp(const struct sun4i_ts_data *ts, long *temp)
127 +static int sun4i_get_temp(const struct sun4i_ts_data *ts, int *temp)
128 {
129 /* No temp_data until the first irq */
130 if (ts->temp_data == -1)
131 @@ -202,7 +202,7 @@ static int sun4i_get_temp(const struct s
132 return 0;
133 }
134
135 -static int sun4i_get_tz_temp(void *data, long *temp)
136 +static int sun4i_get_tz_temp(void *data, int *temp)
137 {
138 return sun4i_get_temp(data, temp);
139 }
140 @@ -215,14 +215,14 @@ static ssize_t show_temp(struct device *
141 char *buf)
142 {
143 struct sun4i_ts_data *ts = dev_get_drvdata(dev);
144 - long temp;
145 + int temp;
146 int error;
147
148 error = sun4i_get_temp(ts, &temp);
149 if (error)
150 return error;
151
152 - return sprintf(buf, "%ld\n", temp);
153 + return sprintf(buf, "%d\n", temp);
154 }
155
156 static ssize_t show_temp_label(struct device *dev,
157 --- a/drivers/platform/x86/acerhdf.c
158 +++ b/drivers/platform/x86/acerhdf.c
159 @@ -346,8 +346,7 @@ static void acerhdf_check_param(struct t
160 * as late as the polling interval is since we can't do that in the respective
161 * accessors of the module parameters.
162 */
163 -static int acerhdf_get_ec_temp(struct thermal_zone_device *thermal,
164 - unsigned long *t)
165 +static int acerhdf_get_ec_temp(struct thermal_zone_device *thermal, int *t)
166 {
167 int temp, err = 0;
168
169 @@ -452,7 +451,7 @@ static int acerhdf_get_trip_type(struct
170 }
171
172 static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip,
173 - unsigned long *temp)
174 + int *temp)
175 {
176 if (trip != 0)
177 return -EINVAL;
178 @@ -463,7 +462,7 @@ static int acerhdf_get_trip_hyst(struct
179 }
180
181 static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
182 - unsigned long *temp)
183 + int *temp)
184 {
185 if (trip == 0)
186 *temp = fanon;
187 @@ -476,7 +475,7 @@ static int acerhdf_get_trip_temp(struct
188 }
189
190 static int acerhdf_get_crit_temp(struct thermal_zone_device *thermal,
191 - unsigned long *temperature)
192 + int *temperature)
193 {
194 *temperature = ACERHDF_TEMP_CRIT;
195 return 0;
196 --- a/drivers/power/power_supply_core.c
197 +++ b/drivers/power/power_supply_core.c
198 @@ -518,7 +518,7 @@ EXPORT_SYMBOL_GPL(power_supply_unreg_not
199
200 #ifdef CONFIG_THERMAL
201 static int power_supply_read_temp(struct thermal_zone_device *tzd,
202 - unsigned long *temp)
203 + int *temp)
204 {
205 struct power_supply *psy;
206 union power_supply_propval val;
207 --- a/drivers/thermal/armada_thermal.c
208 +++ b/drivers/thermal/armada_thermal.c
209 @@ -155,7 +155,7 @@ static bool armada_is_valid(struct armad
210 }
211
212 static int armada_get_temp(struct thermal_zone_device *thermal,
213 - unsigned long *temp)
214 + int *temp)
215 {
216 struct armada_thermal_priv *priv = thermal->devdata;
217 unsigned long reg;
218 --- a/drivers/thermal/db8500_thermal.c
219 +++ b/drivers/thermal/db8500_thermal.c
220 @@ -107,8 +107,7 @@ static int db8500_cdev_unbind(struct the
221 }
222
223 /* Callback to get current temperature */
224 -static int db8500_sys_get_temp(struct thermal_zone_device *thermal,
225 - unsigned long *temp)
226 +static int db8500_sys_get_temp(struct thermal_zone_device *thermal, int *temp)
227 {
228 struct db8500_thermal_zone *pzone = thermal->devdata;
229
230 @@ -180,7 +179,7 @@ static int db8500_sys_get_trip_type(stru
231
232 /* Callback to get trip point temperature */
233 static int db8500_sys_get_trip_temp(struct thermal_zone_device *thermal,
234 - int trip, unsigned long *temp)
235 + int trip, int *temp)
236 {
237 struct db8500_thermal_zone *pzone = thermal->devdata;
238 struct db8500_thsens_platform_data *ptrips = pzone->trip_tab;
239 @@ -195,7 +194,7 @@ static int db8500_sys_get_trip_temp(stru
240
241 /* Callback to get critical trip point temperature */
242 static int db8500_sys_get_crit_temp(struct thermal_zone_device *thermal,
243 - unsigned long *temp)
244 + int *temp)
245 {
246 struct db8500_thermal_zone *pzone = thermal->devdata;
247 struct db8500_thsens_platform_data *ptrips = pzone->trip_tab;
248 --- a/drivers/thermal/dove_thermal.c
249 +++ b/drivers/thermal/dove_thermal.c
250 @@ -93,7 +93,7 @@ static int dove_init_sensor(const struct
251 }
252
253 static int dove_get_temp(struct thermal_zone_device *thermal,
254 - unsigned long *temp)
255 + int *temp)
256 {
257 unsigned long reg;
258 struct dove_thermal_priv *priv = thermal->devdata;
259 --- a/drivers/thermal/fair_share.c
260 +++ b/drivers/thermal/fair_share.c
261 @@ -34,7 +34,7 @@
262 static int get_trip_level(struct thermal_zone_device *tz)
263 {
264 int count = 0;
265 - unsigned long trip_temp;
266 + int trip_temp;
267 enum thermal_trip_type trip_type;
268
269 if (tz->trips == 0 || !tz->ops->get_trip_temp)
270 --- a/drivers/thermal/gov_bang_bang.c
271 +++ b/drivers/thermal/gov_bang_bang.c
272 @@ -25,14 +25,13 @@
273
274 static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
275 {
276 - long trip_temp;
277 - unsigned long trip_hyst;
278 + int trip_temp, trip_hyst;
279 struct thermal_instance *instance;
280
281 tz->ops->get_trip_temp(tz, trip, &trip_temp);
282 tz->ops->get_trip_hyst(tz, trip, &trip_hyst);
283
284 - dev_dbg(&tz->device, "Trip%d[temp=%ld]:temp=%d:hyst=%ld\n",
285 + dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n",
286 trip, trip_temp, tz->temperature,
287 trip_hyst);
288
289 --- a/drivers/thermal/imx_thermal.c
290 +++ b/drivers/thermal/imx_thermal.c
291 @@ -98,10 +98,10 @@ struct imx_thermal_data {
292 enum thermal_device_mode mode;
293 struct regmap *tempmon;
294 u32 c1, c2; /* See formula in imx_get_sensor_data() */
295 - unsigned long temp_passive;
296 - unsigned long temp_critical;
297 - unsigned long alarm_temp;
298 - unsigned long last_temp;
299 + int temp_passive;
300 + int temp_critical;
301 + int alarm_temp;
302 + int last_temp;
303 bool irq_enabled;
304 int irq;
305 struct clk *thermal_clk;
306 @@ -109,7 +109,7 @@ struct imx_thermal_data {
307 };
308
309 static void imx_set_panic_temp(struct imx_thermal_data *data,
310 - signed long panic_temp)
311 + int panic_temp)
312 {
313 struct regmap *map = data->tempmon;
314 int critical_value;
315 @@ -121,7 +121,7 @@ static void imx_set_panic_temp(struct im
316 }
317
318 static void imx_set_alarm_temp(struct imx_thermal_data *data,
319 - signed long alarm_temp)
320 + int alarm_temp)
321 {
322 struct regmap *map = data->tempmon;
323 int alarm_value;
324 @@ -133,7 +133,7 @@ static void imx_set_alarm_temp(struct im
325 TEMPSENSE0_ALARM_VALUE_SHIFT);
326 }
327
328 -static int imx_get_temp(struct thermal_zone_device *tz, unsigned long *temp)
329 +static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
330 {
331 struct imx_thermal_data *data = tz->devdata;
332 struct regmap *map = data->tempmon;
333 @@ -189,13 +189,13 @@ static int imx_get_temp(struct thermal_z
334 if (data->alarm_temp == data->temp_critical &&
335 *temp < data->temp_passive) {
336 imx_set_alarm_temp(data, data->temp_passive);
337 - dev_dbg(&tz->device, "thermal alarm off: T < %lu\n",
338 + dev_dbg(&tz->device, "thermal alarm off: T < %d\n",
339 data->alarm_temp / 1000);
340 }
341 }
342
343 if (*temp != data->last_temp) {
344 - dev_dbg(&tz->device, "millicelsius: %ld\n", *temp);
345 + dev_dbg(&tz->device, "millicelsius: %d\n", *temp);
346 data->last_temp = *temp;
347 }
348
349 @@ -262,8 +262,7 @@ static int imx_get_trip_type(struct ther
350 return 0;
351 }
352
353 -static int imx_get_crit_temp(struct thermal_zone_device *tz,
354 - unsigned long *temp)
355 +static int imx_get_crit_temp(struct thermal_zone_device *tz, int *temp)
356 {
357 struct imx_thermal_data *data = tz->devdata;
358
359 @@ -272,7 +271,7 @@ static int imx_get_crit_temp(struct ther
360 }
361
362 static int imx_get_trip_temp(struct thermal_zone_device *tz, int trip,
363 - unsigned long *temp)
364 + int *temp)
365 {
366 struct imx_thermal_data *data = tz->devdata;
367
368 @@ -282,7 +281,7 @@ static int imx_get_trip_temp(struct ther
369 }
370
371 static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip,
372 - unsigned long temp)
373 + int temp)
374 {
375 struct imx_thermal_data *data = tz->devdata;
376
377 @@ -433,7 +432,7 @@ static irqreturn_t imx_thermal_alarm_irq
378 {
379 struct imx_thermal_data *data = dev;
380
381 - dev_dbg(&data->tz->device, "THERMAL ALARM: T > %lu\n",
382 + dev_dbg(&data->tz->device, "THERMAL ALARM: T > %d\n",
383 data->alarm_temp / 1000);
384
385 thermal_zone_device_update(data->tz);
386 --- a/drivers/thermal/int340x_thermal/int340x_thermal_zone.c
387 +++ b/drivers/thermal/int340x_thermal/int340x_thermal_zone.c
388 @@ -20,7 +20,7 @@
389 #include "int340x_thermal_zone.h"
390
391 static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone,
392 - unsigned long *temp)
393 + int *temp)
394 {
395 struct int34x_thermal_zone *d = zone->devdata;
396 unsigned long long tmp;
397 @@ -49,7 +49,7 @@ static int int340x_thermal_get_zone_temp
398 }
399
400 static int int340x_thermal_get_trip_temp(struct thermal_zone_device *zone,
401 - int trip, unsigned long *temp)
402 + int trip, int *temp)
403 {
404 struct int34x_thermal_zone *d = zone->devdata;
405 int i;
406 @@ -114,7 +114,7 @@ static int int340x_thermal_get_trip_type
407 }
408
409 static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone,
410 - int trip, unsigned long temp)
411 + int trip, int temp)
412 {
413 struct int34x_thermal_zone *d = zone->devdata;
414 acpi_status status;
415 @@ -136,7 +136,7 @@ static int int340x_thermal_set_trip_temp
416
417
418 static int int340x_thermal_get_trip_hyst(struct thermal_zone_device *zone,
419 - int trip, unsigned long *temp)
420 + int trip, int *temp)
421 {
422 struct int34x_thermal_zone *d = zone->devdata;
423 acpi_status status;
424 @@ -163,7 +163,7 @@ static struct thermal_zone_device_ops in
425 };
426
427 static int int340x_thermal_get_trip_config(acpi_handle handle, char *name,
428 - unsigned long *temp)
429 + int *temp)
430 {
431 unsigned long long r;
432 acpi_status status;
433 --- a/drivers/thermal/int340x_thermal/int340x_thermal_zone.h
434 +++ b/drivers/thermal/int340x_thermal/int340x_thermal_zone.h
435 @@ -21,7 +21,7 @@
436 #define INT340X_THERMAL_MAX_ACT_TRIP_COUNT 10
437
438 struct active_trip {
439 - unsigned long temp;
440 + int temp;
441 int id;
442 bool valid;
443 };
444 @@ -31,11 +31,11 @@ struct int34x_thermal_zone {
445 struct active_trip act_trips[INT340X_THERMAL_MAX_ACT_TRIP_COUNT];
446 unsigned long *aux_trips;
447 int aux_trip_nr;
448 - unsigned long psv_temp;
449 + int psv_temp;
450 int psv_trip_id;
451 - unsigned long crt_temp;
452 + int crt_temp;
453 int crt_trip_id;
454 - unsigned long hot_temp;
455 + int hot_temp;
456 int hot_trip_id;
457 struct thermal_zone_device *zone;
458 struct thermal_zone_device_ops *override_ops;
459 --- a/drivers/thermal/intel_soc_dts_thermal.c
460 +++ b/drivers/thermal/intel_soc_dts_thermal.c
461 @@ -106,7 +106,7 @@ err_ret:
462 }
463
464 static int sys_get_trip_temp(struct thermal_zone_device *tzd,
465 - int trip, unsigned long *temp)
466 + int trip, int *temp)
467 {
468 int status;
469 u32 out;
470 @@ -224,7 +224,7 @@ err_restore_ptps:
471 }
472
473 static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
474 - unsigned long temp)
475 + int temp)
476 {
477 struct soc_sensor_entry *aux_entry = tzd->devdata;
478 int status;
479 @@ -250,8 +250,7 @@ static int sys_get_trip_type(struct ther
480 return 0;
481 }
482
483 -static int sys_get_curr_temp(struct thermal_zone_device *tzd,
484 - unsigned long *temp)
485 +static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)
486 {
487 int status;
488 u32 out;
489 --- a/drivers/thermal/of-thermal.c
490 +++ b/drivers/thermal/of-thermal.c
491 @@ -87,7 +87,7 @@ struct __thermal_zone {
492 /*** DT thermal zone device callbacks ***/
493
494 static int of_thermal_get_temp(struct thermal_zone_device *tz,
495 - unsigned long *temp)
496 + int *temp)
497 {
498 struct __thermal_zone *data = tz->devdata;
499
500 @@ -173,7 +173,7 @@ EXPORT_SYMBOL_GPL(of_thermal_get_trip_po
501 * Return: zero on success, error code otherwise
502 */
503 static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
504 - unsigned long temp)
505 + int temp)
506 {
507 struct __thermal_zone *data = tz->devdata;
508
509 @@ -306,7 +306,7 @@ static int of_thermal_get_trip_type(stru
510 }
511
512 static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip,
513 - unsigned long *temp)
514 + int *temp)
515 {
516 struct __thermal_zone *data = tz->devdata;
517
518 @@ -319,7 +319,7 @@ static int of_thermal_get_trip_temp(stru
519 }
520
521 static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
522 - unsigned long temp)
523 + int temp)
524 {
525 struct __thermal_zone *data = tz->devdata;
526
527 @@ -333,7 +333,7 @@ static int of_thermal_set_trip_temp(stru
528 }
529
530 static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int trip,
531 - unsigned long *hyst)
532 + int *hyst)
533 {
534 struct __thermal_zone *data = tz->devdata;
535
536 @@ -346,7 +346,7 @@ static int of_thermal_get_trip_hyst(stru
537 }
538
539 static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip,
540 - unsigned long hyst)
541 + int hyst)
542 {
543 struct __thermal_zone *data = tz->devdata;
544
545 @@ -360,7 +360,7 @@ static int of_thermal_set_trip_hyst(stru
546 }
547
548 static int of_thermal_get_crit_temp(struct thermal_zone_device *tz,
549 - unsigned long *temp)
550 + int *temp)
551 {
552 struct __thermal_zone *data = tz->devdata;
553 int i;
554 --- a/drivers/thermal/rcar_thermal.c
555 +++ b/drivers/thermal/rcar_thermal.c
556 @@ -200,8 +200,7 @@ err_out_unlock:
557 return ret;
558 }
559
560 -static int rcar_thermal_get_temp(struct thermal_zone_device *zone,
561 - unsigned long *temp)
562 +static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
563 {
564 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
565
566 @@ -235,7 +234,7 @@ static int rcar_thermal_get_trip_type(st
567 }
568
569 static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
570 - int trip, unsigned long *temp)
571 + int trip, int *temp)
572 {
573 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
574 struct device *dev = rcar_priv_to_dev(priv);
575 @@ -299,7 +298,7 @@ static void _rcar_thermal_irq_ctrl(struc
576 static void rcar_thermal_work(struct work_struct *work)
577 {
578 struct rcar_thermal_priv *priv;
579 - unsigned long cctemp, nctemp;
580 + int cctemp, nctemp;
581
582 priv = container_of(work, struct rcar_thermal_priv, work.work);
583
584 --- a/drivers/thermal/rockchip_thermal.c
585 +++ b/drivers/thermal/rockchip_thermal.c
586 @@ -64,7 +64,7 @@ struct rockchip_tsadc_chip {
587 void (*control)(void __iomem *reg, bool on);
588
589 /* Per-sensor methods */
590 - int (*get_temp)(int chn, void __iomem *reg, long *temp);
591 + int (*get_temp)(int chn, void __iomem *reg, int *temp);
592 void (*set_tshut_temp)(int chn, void __iomem *reg, long temp);
593 void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m);
594 };
595 @@ -191,7 +191,7 @@ static u32 rk_tsadcv2_temp_to_code(long
596 return 0;
597 }
598
599 -static long rk_tsadcv2_code_to_temp(u32 code)
600 +static int rk_tsadcv2_code_to_temp(u32 code)
601 {
602 unsigned int low = 0;
603 unsigned int high = ARRAY_SIZE(v2_code_table) - 1;
604 @@ -277,7 +277,7 @@ static void rk_tsadcv2_control(void __io
605 writel_relaxed(val, regs + TSADCV2_AUTO_CON);
606 }
607
608 -static int rk_tsadcv2_get_temp(int chn, void __iomem *regs, long *temp)
609 +static int rk_tsadcv2_get_temp(int chn, void __iomem *regs, int *temp)
610 {
611 u32 val;
612
613 @@ -366,7 +366,7 @@ static irqreturn_t rockchip_thermal_alar
614 return IRQ_HANDLED;
615 }
616
617 -static int rockchip_thermal_get_temp(void *_sensor, long *out_temp)
618 +static int rockchip_thermal_get_temp(void *_sensor, int *out_temp)
619 {
620 struct rockchip_thermal_sensor *sensor = _sensor;
621 struct rockchip_thermal_data *thermal = sensor->thermal;
622 @@ -374,7 +374,7 @@ static int rockchip_thermal_get_temp(voi
623 int retval;
624
625 retval = tsadc->get_temp(sensor->id, thermal->regs, out_temp);
626 - dev_dbg(&thermal->pdev->dev, "sensor %d - temp: %ld, retval: %d\n",
627 + dev_dbg(&thermal->pdev->dev, "sensor %d - temp: %d, retval: %d\n",
628 sensor->id, *out_temp, retval);
629
630 return retval;
631 --- a/drivers/thermal/samsung/exynos_tmu.c
632 +++ b/drivers/thermal/samsung/exynos_tmu.c
633 @@ -181,8 +181,7 @@ struct exynos_tmu_data {
634 int (*tmu_initialize)(struct platform_device *pdev);
635 void (*tmu_control)(struct platform_device *pdev, bool on);
636 int (*tmu_read)(struct exynos_tmu_data *data);
637 - void (*tmu_set_emulation)(struct exynos_tmu_data *data,
638 - unsigned long temp);
639 + void (*tmu_set_emulation)(struct exynos_tmu_data *data, int temp);
640 void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
641 };
642
643 @@ -190,7 +189,7 @@ static void exynos_report_trigger(struct
644 {
645 char data[10], *envp[] = { data, NULL };
646 struct thermal_zone_device *tz = p->tzd;
647 - unsigned long temp;
648 + int temp;
649 unsigned int i;
650
651 if (!tz) {
652 @@ -489,7 +488,7 @@ static int exynos5440_tmu_initialize(str
653 struct exynos_tmu_data *data = platform_get_drvdata(pdev);
654 unsigned int trim_info = 0, con, rising_threshold;
655 int ret = 0, threshold_code;
656 - unsigned long crit_temp = 0;
657 + int crit_temp = 0;
658
659 /*
660 * For exynos5440 soc triminfo value is swapped between TMU0 and
661 @@ -542,7 +541,7 @@ static int exynos7_tmu_initialize(struct
662 unsigned int status, trim_info;
663 unsigned int rising_threshold = 0, falling_threshold = 0;
664 int ret = 0, threshold_code, i;
665 - unsigned long temp, temp_hist;
666 + int temp, temp_hist;
667 unsigned int reg_off, bit_off;
668
669 status = readb(data->base + EXYNOS_TMU_REG_STATUS);
670 @@ -713,7 +712,7 @@ static void exynos7_tmu_control(struct p
671 writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
672 }
673
674 -static int exynos_get_temp(void *p, long *temp)
675 +static int exynos_get_temp(void *p, int *temp)
676 {
677 struct exynos_tmu_data *data = p;
678
679 @@ -733,7 +732,7 @@ static int exynos_get_temp(void *p, long
680
681 #ifdef CONFIG_THERMAL_EMULATION
682 static u32 get_emul_con_reg(struct exynos_tmu_data *data, unsigned int val,
683 - unsigned long temp)
684 + int temp)
685 {
686 if (temp) {
687 temp /= MCELSIUS;
688 @@ -763,7 +762,7 @@ static u32 get_emul_con_reg(struct exyno
689 }
690
691 static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data,
692 - unsigned long temp)
693 + int temp)
694 {
695 unsigned int val;
696 u32 emul_con;
697 @@ -781,7 +780,7 @@ static void exynos4412_tmu_set_emulation
698 }
699
700 static void exynos5440_tmu_set_emulation(struct exynos_tmu_data *data,
701 - unsigned long temp)
702 + int temp)
703 {
704 unsigned int val;
705
706 @@ -790,7 +789,7 @@ static void exynos5440_tmu_set_emulation
707 writel(val, data->base + EXYNOS5440_TMU_S0_7_DEBUG);
708 }
709
710 -static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp)
711 +static int exynos_tmu_set_emulation(void *drv_data, int temp)
712 {
713 struct exynos_tmu_data *data = drv_data;
714 int ret = -EINVAL;
715 --- a/drivers/thermal/spear_thermal.c
716 +++ b/drivers/thermal/spear_thermal.c
717 @@ -38,7 +38,7 @@ struct spear_thermal_dev {
718 };
719
720 static inline int thermal_get_temp(struct thermal_zone_device *thermal,
721 - unsigned long *temp)
722 + int *temp)
723 {
724 struct spear_thermal_dev *stdev = thermal->devdata;
725
726 --- a/drivers/thermal/st/st_thermal.c
727 +++ b/drivers/thermal/st/st_thermal.c
728 @@ -111,8 +111,7 @@ static int st_thermal_calibration(struct
729 }
730
731 /* Callback to get temperature from HW*/
732 -static int st_thermal_get_temp(struct thermal_zone_device *th,
733 - unsigned long *temperature)
734 +static int st_thermal_get_temp(struct thermal_zone_device *th, int *temperature)
735 {
736 struct st_thermal_sensor *sensor = th->devdata;
737 struct device *dev = sensor->dev;
738 @@ -159,7 +158,7 @@ static int st_thermal_get_trip_type(stru
739 }
740
741 static int st_thermal_get_trip_temp(struct thermal_zone_device *th,
742 - int trip, unsigned long *temp)
743 + int trip, int *temp)
744 {
745 struct st_thermal_sensor *sensor = th->devdata;
746 struct device *dev = sensor->dev;
747 --- a/drivers/thermal/step_wise.c
748 +++ b/drivers/thermal/step_wise.c
749 @@ -113,7 +113,7 @@ static void update_passive_instance(stru
750
751 static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
752 {
753 - long trip_temp;
754 + int trip_temp;
755 enum thermal_trip_type trip_type;
756 enum thermal_trend trend;
757 struct thermal_instance *instance;
758 @@ -135,7 +135,7 @@ static void thermal_zone_trip_update(str
759 trace_thermal_zone_trip(tz, trip, trip_type);
760 }
761
762 - dev_dbg(&tz->device, "Trip%d[type=%d,temp=%ld]:trend=%d,throttle=%d\n",
763 + dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n",
764 trip, trip_type, trip_temp, trend, throttle);
765
766 mutex_lock(&tz->lock);
767 --- a/drivers/thermal/tegra_soctherm.c
768 +++ b/drivers/thermal/tegra_soctherm.c
769 @@ -293,7 +293,7 @@ static int enable_tsensor(struct tegra_s
770 * H denotes an addition of 0.5 Celsius and N denotes negation
771 * of the final value.
772 */
773 -static long translate_temp(u16 val)
774 +static int translate_temp(u16 val)
775 {
776 long t;
777
778 @@ -306,7 +306,7 @@ static long translate_temp(u16 val)
779 return t;
780 }
781
782 -static int tegra_thermctl_get_temp(void *data, long *out_temp)
783 +static int tegra_thermctl_get_temp(void *data, int *out_temp)
784 {
785 struct tegra_thermctl_zone *zone = data;
786 u32 val;
787 --- a/drivers/thermal/thermal_core.c
788 +++ b/drivers/thermal/thermal_core.c
789 @@ -363,7 +363,7 @@ static void handle_non_critical_trips(st
790 static void handle_critical_trips(struct thermal_zone_device *tz,
791 int trip, enum thermal_trip_type trip_type)
792 {
793 - long trip_temp;
794 + int trip_temp;
795
796 tz->ops->get_trip_temp(tz, trip, &trip_temp);
797
798 @@ -411,12 +411,12 @@ static void handle_thermal_trip(struct t
799 *
800 * Return: On success returns 0, an error code otherwise
801 */
802 -int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp)
803 +int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
804 {
805 int ret = -EINVAL;
806 #ifdef CONFIG_THERMAL_EMULATION
807 int count;
808 - unsigned long crit_temp = -1UL;
809 + int crit_temp = INT_MAX;
810 enum thermal_trip_type type;
811 #endif
812
813 @@ -453,8 +453,7 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_temp)
814
815 static void update_temperature(struct thermal_zone_device *tz)
816 {
817 - long temp;
818 - int ret;
819 + int temp, ret;
820
821 ret = thermal_zone_get_temp(tz, &temp);
822 if (ret) {
823 @@ -514,15 +513,14 @@ static ssize_t
824 temp_show(struct device *dev, struct device_attribute *attr, char *buf)
825 {
826 struct thermal_zone_device *tz = to_thermal_zone(dev);
827 - long temperature;
828 - int ret;
829 + int temperature, ret;
830
831 ret = thermal_zone_get_temp(tz, &temperature);
832
833 if (ret)
834 return ret;
835
836 - return sprintf(buf, "%ld\n", temperature);
837 + return sprintf(buf, "%d\n", temperature);
838 }
839
840 static ssize_t
841 @@ -626,7 +624,7 @@ trip_point_temp_show(struct device *dev,
842 {
843 struct thermal_zone_device *tz = to_thermal_zone(dev);
844 int trip, ret;
845 - long temperature;
846 + int temperature;
847
848 if (!tz->ops->get_trip_temp)
849 return -EPERM;
850 @@ -639,7 +637,7 @@ trip_point_temp_show(struct device *dev,
851 if (ret)
852 return ret;
853
854 - return sprintf(buf, "%ld\n", temperature);
855 + return sprintf(buf, "%d\n", temperature);
856 }
857
858 static ssize_t
859 @@ -648,7 +646,7 @@ trip_point_hyst_store(struct device *dev
860 {
861 struct thermal_zone_device *tz = to_thermal_zone(dev);
862 int trip, ret;
863 - unsigned long temperature;
864 + int temperature;
865
866 if (!tz->ops->set_trip_hyst)
867 return -EPERM;
868 @@ -656,7 +654,7 @@ trip_point_hyst_store(struct device *dev
869 if (!sscanf(attr->attr.name, "trip_point_%d_hyst", &trip))
870 return -EINVAL;
871
872 - if (kstrtoul(buf, 10, &temperature))
873 + if (kstrtoint(buf, 10, &temperature))
874 return -EINVAL;
875
876 /*
877 @@ -675,7 +673,7 @@ trip_point_hyst_show(struct device *dev,
878 {
879 struct thermal_zone_device *tz = to_thermal_zone(dev);
880 int trip, ret;
881 - unsigned long temperature;
882 + int temperature;
883
884 if (!tz->ops->get_trip_hyst)
885 return -EPERM;
886 @@ -685,7 +683,7 @@ trip_point_hyst_show(struct device *dev,
887
888 ret = tz->ops->get_trip_hyst(tz, trip, &temperature);
889
890 - return ret ? ret : sprintf(buf, "%ld\n", temperature);
891 + return ret ? ret : sprintf(buf, "%d\n", temperature);
892 }
893
894 static ssize_t
895 --- a/drivers/thermal/thermal_hwmon.c
896 +++ b/drivers/thermal/thermal_hwmon.c
897 @@ -69,7 +69,7 @@ static DEVICE_ATTR(name, 0444, name_show
898 static ssize_t
899 temp_input_show(struct device *dev, struct device_attribute *attr, char *buf)
900 {
901 - long temperature;
902 + int temperature;
903 int ret;
904 struct thermal_hwmon_attr *hwmon_attr
905 = container_of(attr, struct thermal_hwmon_attr, attr);
906 @@ -83,7 +83,7 @@ temp_input_show(struct device *dev, stru
907 if (ret)
908 return ret;
909
910 - return sprintf(buf, "%ld\n", temperature);
911 + return sprintf(buf, "%d\n", temperature);
912 }
913
914 static ssize_t
915 @@ -95,14 +95,14 @@ temp_crit_show(struct device *dev, struc
916 = container_of(hwmon_attr, struct thermal_hwmon_temp,
917 temp_crit);
918 struct thermal_zone_device *tz = temp->tz;
919 - long temperature;
920 + int temperature;
921 int ret;
922
923 ret = tz->ops->get_trip_temp(tz, 0, &temperature);
924 if (ret)
925 return ret;
926
927 - return sprintf(buf, "%ld\n", temperature);
928 + return sprintf(buf, "%d\n", temperature);
929 }
930
931
932 @@ -142,7 +142,7 @@ thermal_hwmon_lookup_temp(const struct t
933
934 static bool thermal_zone_crit_temp_valid(struct thermal_zone_device *tz)
935 {
936 - unsigned long temp;
937 + int temp;
938 return tz->ops->get_crit_temp && !tz->ops->get_crit_temp(tz, &temp);
939 }
940
941 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
942 +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
943 @@ -76,14 +76,14 @@ static inline int ti_thermal_hotspot_tem
944
945 /* thermal zone ops */
946 /* Get temperature callback function for thermal zone*/
947 -static inline int __ti_thermal_get_temp(void *devdata, long *temp)
948 +static inline int __ti_thermal_get_temp(void *devdata, int *temp)
949 {
950 struct thermal_zone_device *pcb_tz = NULL;
951 struct ti_thermal_data *data = devdata;
952 struct ti_bandgap *bgp;
953 const struct ti_temp_sensor *s;
954 int ret, tmp, slope, constant;
955 - unsigned long pcb_temp;
956 + int pcb_temp;
957
958 if (!data)
959 return 0;
960 @@ -119,7 +119,7 @@ static inline int __ti_thermal_get_temp(
961 }
962
963 static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
964 - unsigned long *temp)
965 + int *temp)
966 {
967 struct ti_thermal_data *data = thermal->devdata;
968
969 @@ -228,7 +228,7 @@ static int ti_thermal_get_trip_type(stru
970
971 /* Get trip temperature callback functions for thermal zone */
972 static int ti_thermal_get_trip_temp(struct thermal_zone_device *thermal,
973 - int trip, unsigned long *temp)
974 + int trip, int *temp)
975 {
976 if (!ti_thermal_is_valid_trip(trip))
977 return -EINVAL;
978 @@ -279,7 +279,7 @@ static int ti_thermal_get_trend(struct t
979
980 /* Get critical temperature callback functions for thermal zone */
981 static int ti_thermal_get_crit_temp(struct thermal_zone_device *thermal,
982 - unsigned long *temp)
983 + int *temp)
984 {
985 /* shutdown zone */
986 return ti_thermal_get_trip_temp(thermal, OMAP_TRIP_NUMBER - 1, temp);
987 --- a/drivers/thermal/x86_pkg_temp_thermal.c
988 +++ b/drivers/thermal/x86_pkg_temp_thermal.c
989 @@ -164,7 +164,7 @@ err_ret:
990 return err;
991 }
992
993 -static int sys_get_curr_temp(struct thermal_zone_device *tzd, unsigned long *temp)
994 +static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)
995 {
996 u32 eax, edx;
997 struct phy_dev_entry *phy_dev_entry;
998 @@ -175,7 +175,7 @@ static int sys_get_curr_temp(struct ther
999 if (eax & 0x80000000) {
1000 *temp = phy_dev_entry->tj_max -
1001 ((eax >> 16) & 0x7f) * 1000;
1002 - pr_debug("sys_get_curr_temp %ld\n", *temp);
1003 + pr_debug("sys_get_curr_temp %d\n", *temp);
1004 return 0;
1005 }
1006
1007 @@ -183,7 +183,7 @@ static int sys_get_curr_temp(struct ther
1008 }
1009
1010 static int sys_get_trip_temp(struct thermal_zone_device *tzd,
1011 - int trip, unsigned long *temp)
1012 + int trip, int *temp)
1013 {
1014 u32 eax, edx;
1015 struct phy_dev_entry *phy_dev_entry;
1016 @@ -214,13 +214,13 @@ static int sys_get_trip_temp(struct ther
1017 *temp = phy_dev_entry->tj_max - thres_reg_value * 1000;
1018 else
1019 *temp = 0;
1020 - pr_debug("sys_get_trip_temp %ld\n", *temp);
1021 + pr_debug("sys_get_trip_temp %d\n", *temp);
1022
1023 return 0;
1024 }
1025
1026 static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
1027 - unsigned long temp)
1028 + int temp)
1029 {
1030 u32 l, h;
1031 struct phy_dev_entry *phy_dev_entry;
1032 --- a/include/linux/thermal.h
1033 +++ b/include/linux/thermal.h
1034 @@ -86,23 +86,19 @@ struct thermal_zone_device_ops {
1035 struct thermal_cooling_device *);
1036 int (*unbind) (struct thermal_zone_device *,
1037 struct thermal_cooling_device *);
1038 - int (*get_temp) (struct thermal_zone_device *, unsigned long *);
1039 + int (*get_temp) (struct thermal_zone_device *, int *);
1040 int (*get_mode) (struct thermal_zone_device *,
1041 enum thermal_device_mode *);
1042 int (*set_mode) (struct thermal_zone_device *,
1043 enum thermal_device_mode);
1044 int (*get_trip_type) (struct thermal_zone_device *, int,
1045 enum thermal_trip_type *);
1046 - int (*get_trip_temp) (struct thermal_zone_device *, int,
1047 - unsigned long *);
1048 - int (*set_trip_temp) (struct thermal_zone_device *, int,
1049 - unsigned long);
1050 - int (*get_trip_hyst) (struct thermal_zone_device *, int,
1051 - unsigned long *);
1052 - int (*set_trip_hyst) (struct thermal_zone_device *, int,
1053 - unsigned long);
1054 - int (*get_crit_temp) (struct thermal_zone_device *, unsigned long *);
1055 - int (*set_emul_temp) (struct thermal_zone_device *, unsigned long);
1056 + int (*get_trip_temp) (struct thermal_zone_device *, int, int *);
1057 + int (*set_trip_temp) (struct thermal_zone_device *, int, int);
1058 + int (*get_trip_hyst) (struct thermal_zone_device *, int, int *);
1059 + int (*set_trip_hyst) (struct thermal_zone_device *, int, int);
1060 + int (*get_crit_temp) (struct thermal_zone_device *, int *);
1061 + int (*set_emul_temp) (struct thermal_zone_device *, int);
1062 int (*get_trend) (struct thermal_zone_device *, int,
1063 enum thermal_trend *);
1064 int (*notify) (struct thermal_zone_device *, int,
1065 @@ -272,9 +268,9 @@ struct thermal_genl_event {
1066 * temperature.
1067 */
1068 struct thermal_zone_of_device_ops {
1069 - int (*get_temp)(void *, long *);
1070 + int (*get_temp)(void *, int *);
1071 int (*get_trend)(void *, long *);
1072 - int (*set_emul_temp)(void *, unsigned long);
1073 + int (*set_emul_temp)(void *, int);
1074 };
1075
1076 /**
1077 @@ -335,7 +331,7 @@ thermal_of_cooling_device_register(struc
1078 const struct thermal_cooling_device_ops *);
1079 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
1080 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
1081 -int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
1082 +int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
1083
1084 int get_tz_trend(struct thermal_zone_device *, int);
1085 struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
1086 @@ -378,7 +374,7 @@ static inline struct thermal_zone_device
1087 const char *name)
1088 { return ERR_PTR(-ENODEV); }
1089 static inline int thermal_zone_get_temp(
1090 - struct thermal_zone_device *tz, unsigned long *temp)
1091 + struct thermal_zone_device *tz, int *temp)
1092 { return -ENODEV; }
1093 static inline int get_tz_trend(struct thermal_zone_device *tz, int trip)
1094 { return -ENODEV; }