Skip to contentSkip to conversation

thermal: consistently use int for trip temp

PATCH In review Wei Ni 2 participants 6 messages Mar 3, 2016 – Apr 12, 2016 Thermal

lore
Share & tools
lore

Wei Ni

author
#0 lore raw

PATCH v2 1/1 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.

---
 drivers/thermal/thermal_core.c | 8 ++++----
 include/linux/thermal.h        | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/thermal/thermal_core.c +4 -4
index a0a8fd1235e2..e838786fedd8 100644
@@ -684,7 +684,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;
@@ -692,7 +692,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);
@@ -895,9 +895,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) {
include/linux/thermal.h +2 -2
index e13a1ace50e9..eee0b7ddd2c1 100644
@@ -350,8 +350,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;
 };
 
Signature · 1 line
1.9.1
author
#1 lore raw

There had a build error in previous patch.
Fixed it in this version.
Please review it.

Thanks.
Wei.

Quoted 66 lines · Wei Ni

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.

---
 drivers/thermal/thermal_core.c | 8 ++++----
 include/linux/thermal.h        | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/thermal/thermal_core.c +4 -4
index a0a8fd1235e2..e838786fedd8 100644
@@ -684,7 +684,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;
@@ -692,7 +692,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);
@@ -895,9 +895,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) {
include/linux/thermal.h +2 -2
index e13a1ace50e9..eee0b7ddd2c1 100644
@@ -350,8 +350,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;
 };
 
author
#2 lore raw
Quoted 3 lines · Wei Ni

There had a build error in previous patch.
Fixed it in this version.
Please review it.

Add CC: [email protected]

Quoted 71 lines

Thanks.
Wei.

Quoted 66 lines · Wei Ni

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.

---
 drivers/thermal/thermal_core.c | 8 ++++----
 include/linux/thermal.h        | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/thermal/thermal_core.c +4 -4
index a0a8fd1235e2..e838786fedd8 100644
@@ -684,7 +684,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;
@@ -692,7 +692,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);
@@ -895,9 +895,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) {
include/linux/thermal.h +2 -2
index e13a1ace50e9..eee0b7ddd2c1 100644
@@ -350,8 +350,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;
 };
 
#3 lore raw
Quoted 25 lines · Wei Ni
Quoted 3 lines · Wei Ni

There had a build error in previous patch.
Fixed it in this version.
Please review it.

Add CC: [email protected]

Quoted 16 lines

Thanks.
Wei.

Quoted 11 lines · Wei Ni

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.

Rui are you collecting this one?

author
#4 lore raw
Quoted 10 lines · Eduardo Valentin
Quoted 9 lines · Wei Ni
Quoted 3 lines · Wei Ni

There had a build error in previous patch.
Fixed it in this version.
Please review it.

Add CC: [email protected]

Hi Rui,
Will you take this patch?

Quoted 21 lines
Quoted 8 lines
Quoted 8 lines

Thanks.
Wei.

Quoted 3 lines · Wei Ni

The commit 17e8351a7739 consistently use int for temperature, however it missed a few in trip temperature and thermal_core.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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.

Rui are you collecting this one?

author
#5 lore raw
Quoted 11 lines · Wei Ni
Quoted 8 lines · Eduardo Valentin
Quoted 7 lines · Wei Ni
Quoted 3 lines · Wei Ni

There had a build error in previous patch.
Fixed it in this version.
Please review it.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Add CC: [email protected]

Hi Rui,
Will you take this patch?

Rui, could you please take a look this patch?

Quoted 27 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

Thanks.
Wei.

Quoted 8 lines · Wei Ni

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.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

This patch can fix it.

Rui are you collecting this one?

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html