aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-07-24 02:12:54 -0400
committerZhang Rui <rui.zhang@intel.com>2015-08-03 11:15:50 -0400
commit17e8351a77397e8a83727eb17e3a3e9b8ab5257a (patch)
tree9087ea501d32baa56842d112c071cbe57eede870 /drivers/platform
parent25a0a5ce16ecd7e60c4cf1436892433873e9d99d (diff)
thermal: consistently use int for temperatures
The thermal code uses int, long and unsigned long for temperatures in different places. Using an unsigned type limits the thermal framework to positive temperatures without need. Also several drivers currently will report temperatures near UINT_MAX for temperatures below 0°C. This will probably immediately shut the machine down due to overtemperature if started below 0°C. 'long' is 64bit on several architectures. This is not needed since INT_MAX °mC is above the melting point of all known materials. Consistently use a plain 'int' for temperatures throughout the thermal code and the drivers. This only changes the places in the drivers where the temperature is passed around as pointer, when drivers internally use another type this is not changed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Jean Delvare <jdelvare@suse.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com> Reviewed-by: Darren Hart <dvhart@linux.intel.com> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Reviewed-by: Peter Feuerer <peter@piie.net> Cc: Punit Agrawal <punit.agrawal@arm.com> Cc: Zhang Rui <rui.zhang@intel.com> Cc: Eduardo Valentin <edubezval@gmail.com> Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Jean Delvare <jdelvare@suse.de> Cc: Peter Feuerer <peter@piie.net> Cc: Heiko Stuebner <heiko@sntech.de> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: Stephen Warren <swarren@wwwdotorg.org> Cc: Thierry Reding <thierry.reding@gmail.com> Cc: linux-acpi@vger.kernel.org Cc: platform-driver-x86@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-omap@vger.kernel.org Cc: linux-samsung-soc@vger.kernel.org Cc: Guenter Roeck <linux@roeck-us.net> Cc: Rafael J. Wysocki <rjw@rjwysocki.net> Cc: Maxime Ripard <maxime.ripard@free-electrons.com> Cc: Darren Hart <dvhart@infradead.org> Cc: lm-sensors@lm-sensors.org Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/acerhdf.c9
-rw-r--r--drivers/platform/x86/intel_mid_thermal.c9
2 files changed, 8 insertions, 10 deletions
diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index 1ef02daddb60..460fa6708bfc 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -346,8 +346,7 @@ static void acerhdf_check_param(struct thermal_zone_device *thermal)
346 * as late as the polling interval is since we can't do that in the respective 346 * as late as the polling interval is since we can't do that in the respective
347 * accessors of the module parameters. 347 * accessors of the module parameters.
348 */ 348 */
349static int acerhdf_get_ec_temp(struct thermal_zone_device *thermal, 349static int acerhdf_get_ec_temp(struct thermal_zone_device *thermal, int *t)
350 unsigned long *t)
351{ 350{
352 int temp, err = 0; 351 int temp, err = 0;
353 352
@@ -453,7 +452,7 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
453} 452}
454 453
455static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip, 454static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip,
456 unsigned long *temp) 455 int *temp)
457{ 456{
458 if (trip != 0) 457 if (trip != 0)
459 return -EINVAL; 458 return -EINVAL;
@@ -464,7 +463,7 @@ static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int trip,
464} 463}
465 464
466static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip, 465static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
467 unsigned long *temp) 466 int *temp)
468{ 467{
469 if (trip == 0) 468 if (trip == 0)
470 *temp = fanon; 469 *temp = fanon;
@@ -477,7 +476,7 @@ static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
477} 476}
478 477
479static int acerhdf_get_crit_temp(struct thermal_zone_device *thermal, 478static int acerhdf_get_crit_temp(struct thermal_zone_device *thermal,
480 unsigned long *temperature) 479 int *temperature)
481{ 480{
482 *temperature = ACERHDF_TEMP_CRIT; 481 *temperature = ACERHDF_TEMP_CRIT;
483 return 0; 482 return 0;
diff --git a/drivers/platform/x86/intel_mid_thermal.c b/drivers/platform/x86/intel_mid_thermal.c
index 0944e834af8d..9f713b832ba3 100644
--- a/drivers/platform/x86/intel_mid_thermal.c
+++ b/drivers/platform/x86/intel_mid_thermal.c
@@ -132,7 +132,7 @@ static int is_valid_adc(uint16_t adc_val, uint16_t min, uint16_t max)
132 * to achieve very close approximate temp value with less than 132 * to achieve very close approximate temp value with less than
133 * 0.5C error 133 * 0.5C error
134 */ 134 */
135static int adc_to_temp(int direct, uint16_t adc_val, unsigned long *tp) 135static int adc_to_temp(int direct, uint16_t adc_val, int *tp)
136{ 136{
137 int temp; 137 int temp;
138 138
@@ -174,14 +174,13 @@ static int adc_to_temp(int direct, uint16_t adc_val, unsigned long *tp)
174 * 174 *
175 * Can sleep 175 * Can sleep
176 */ 176 */
177static int mid_read_temp(struct thermal_zone_device *tzd, unsigned long *temp) 177static int mid_read_temp(struct thermal_zone_device *tzd, int *temp)
178{ 178{
179 struct thermal_device_info *td_info = tzd->devdata; 179 struct thermal_device_info *td_info = tzd->devdata;
180 uint16_t adc_val, addr; 180 uint16_t adc_val, addr;
181 uint8_t data = 0; 181 uint8_t data = 0;
182 int ret; 182 int ret;
183 unsigned long curr_temp; 183 int curr_temp;
184
185 184
186 addr = td_info->chnl_addr; 185 addr = td_info->chnl_addr;
187 186
@@ -453,7 +452,7 @@ static SIMPLE_DEV_PM_OPS(mid_thermal_pm,
453 * 452 *
454 * Can sleep 453 * Can sleep
455 */ 454 */
456static int read_curr_temp(struct thermal_zone_device *tzd, unsigned long *temp) 455static int read_curr_temp(struct thermal_zone_device *tzd, int *temp)
457{ 456{
458 WARN_ON(tzd == NULL); 457 WARN_ON(tzd == NULL);
459 return mid_read_temp(tzd, temp); 458 return mid_read_temp(tzd, temp);