From: Wei Ni Date: Thu, 3 Mar 2016 09:33:46 +0000 (+0800) Subject: UPSTREAM: thermal: consistently use int for trip temp X-Git-Tag: firefly_0821_release~2658 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=acb72fede655d6024631bc9a2a6ef1b8fca7eed0;p=firefly-linux-kernel-4.4.55.git UPSTREAM: thermal: consistently use int for trip temp The commit 17e8351a7739 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. Change-Id: I4b31f577a6142bc02f8e0deae79ab2ff7c8bd978 Signed-off-by: Wei Ni Signed-off-by: Eduardo Valentin Signed-off-by: Finley Xiao (cherry picked from commit 1d0fd42fa31d18ba0a3e0dd008c9e93e1cebe451) --- diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 05a35b748264..b86a2b36c924 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -727,7 +727,7 @@ 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; @@ -735,7 +735,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr, 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); @@ -940,9 +940,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) { diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 7fd6d05550c0..1423eaff9ac3 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -358,8 +358,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; };