Skip to content

Commit

Permalink
thermal: consistently use int for trip temp
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wei Ni authored and Eduardo Valentin committed Apr 21, 2016
1 parent 62e14f6 commit 1d0fd42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions drivers/thermal/thermal_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,15 +688,15 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
{
struct thermal_zone_device *tz = to_thermal_zone(dev);
int trip, ret;
unsigned long temperature;
int temperature;

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

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

if (kstrtoul(buf, 10, &temperature))
if (kstrtoint(buf, 10, &temperature))
return -EINVAL;

ret = tz->ops->set_trip_temp(tz, trip, temperature);
Expand Down Expand Up @@ -899,9 +899,9 @@ emul_temp_store(struct device *dev, struct device_attribute *attr,
{
struct thermal_zone_device *tz = to_thermal_zone(dev);
int ret = 0;
unsigned long temperature;
int temperature;

if (kstrtoul(buf, 10, &temperature))
if (kstrtoint(buf, 10, &temperature))
return -EINVAL;

if (!tz->ops->set_emul_temp) {
Expand Down
4 changes: 2 additions & 2 deletions include/linux/thermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ struct thermal_zone_of_device_ops {

struct thermal_trip {
struct device_node *np;
unsigned long int temperature;
unsigned long int hysteresis;
int temperature;
int hysteresis;
enum thermal_trip_type type;
};

Expand Down

0 comments on commit 1d0fd42

Please sign in to comment.