Skip to content

Commit 1d0fd42

Browse files
wni-WeiNiEduardo Valentin
authored andcommitted
thermal: consistently use int for trip temp
The commit 17e8351 consistently use int for temperature, however it missed a few in trip temperature and thermal_core. In current codes, the trip->temperature used "unsigned long" and zone->temperature used"int", if the temperature is negative value, it will get wrong result when compare temperature with trip temperature. This patch can fix it. Signed-off-by: Wei Ni <wni@nvidia.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
1 parent 62e14f6 commit 1d0fd42

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

drivers/thermal/thermal_core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,15 +688,15 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
688688
{
689689
struct thermal_zone_device *tz = to_thermal_zone(dev);
690690
int trip, ret;
691-
unsigned long temperature;
691+
int temperature;
692692

693693
if (!tz->ops->set_trip_temp)
694694
return -EPERM;
695695

696696
if (!sscanf(attr->attr.name, "trip_point_%d_temp", &trip))
697697
return -EINVAL;
698698

699-
if (kstrtoul(buf, 10, &temperature))
699+
if (kstrtoint(buf, 10, &temperature))
700700
return -EINVAL;
701701

702702
ret = tz->ops->set_trip_temp(tz, trip, temperature);
@@ -899,9 +899,9 @@ emul_temp_store(struct device *dev, struct device_attribute *attr,
899899
{
900900
struct thermal_zone_device *tz = to_thermal_zone(dev);
901901
int ret = 0;
902-
unsigned long temperature;
902+
int temperature;
903903

904-
if (kstrtoul(buf, 10, &temperature))
904+
if (kstrtoint(buf, 10, &temperature))
905905
return -EINVAL;
906906

907907
if (!tz->ops->set_emul_temp) {

include/linux/thermal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ struct thermal_zone_of_device_ops {
352352

353353
struct thermal_trip {
354354
struct device_node *np;
355-
unsigned long int temperature;
356-
unsigned long int hysteresis;
355+
int temperature;
356+
int hysteresis;
357357
enum thermal_trip_type type;
358358
};
359359

0 commit comments

Comments
 (0)