Skip to contentSkip to conversation

thermal: of: Match trip property helper types

PATCH Applied Rob Herring (Arm) 4 participants 5 messages Jun 12 – Oct 14 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: of: Match trip property helper types

The thermal-zone binding defines "temperature" as a signed int32 value and "hysteresis" as an unsigned int32 value. Using helpers with matching types avoids dt_property_check mismatches and preserves the signed interpretation needed for trips below zero.

Read "temperature" with the signed helper and keep "hysteresis" on the unsigned helper using separate typed temporaries before storing them in the trip structure.

Assisted-by Codex:gpt-5-5
---
 drivers/thermal/thermal_of.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/thermal/thermal_of.c +6 -5
index 99085c806a1f..196cb29afae9 100644
@@ -63,22 +63,23 @@ static int thermal_of_get_trip_type(struct device_node *np,
 static int thermal_of_populate_trip(struct device_node *np,
 				    struct thermal_trip *trip)
 {
-	int prop;
+	u32 hysteresis;
+	s32 temperature;
 	int ret;
 
-	ret = of_property_read_u32(np, "temperature", &prop);
+	ret = of_property_read_s32(np, "temperature", &temperature);
 	if (ret < 0) {
 		pr_err("missing temperature property\n");
 		return ret;
 	}
-	trip->temperature = prop;
+	trip->temperature = temperature;
 
-	ret = of_property_read_u32(np, "hysteresis", &prop);
+	ret = of_property_read_u32(np, "hysteresis", &hysteresis);
 	if (ret < 0) {
 		pr_err("missing hysteresis property\n");
 		return ret;
 	}
-	trip->hysteresis = prop;
+	trip->hysteresis = hysteresis;
 
 	ret = thermal_of_get_trip_type(np, &trip->type);
 	if (ret < 0) {
Signature · 1 line
2.53.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 38 lines · Rob Herring (Arm)

The thermal-zone binding defines "temperature" as a signed int32 value and "hysteresis" as an unsigned int32 value. Using helpers with matching types avoids dt_property_check mismatches and preserves the signed interpretation needed for trips below zero.

Read "temperature" with the signed helper and keep "hysteresis" on the unsigned helper using separate typed temporaries before storing them in the trip structure.

Assisted-by Codex:gpt-5-5
---
  drivers/thermal/thermal_of.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)
drivers/thermal/thermal_of.c +4 -4
index 99085c806a1f..196cb29afae9 100644
@@ -63,22 +63,23 @@ static int thermal_of_get_trip_type(struct device_node *np,
  static int thermal_of_populate_trip(struct device_node *np,
  				    struct thermal_trip *trip)
  {
-	int prop;
+	u32 hysteresis;
+	s32 temperature;
  	int ret;
 
-	ret = of_property_read_u32(np, "temperature", &prop);
+	ret = of_property_read_s32(np, "temperature", &temperature);
  	if (ret < 0) {
  		pr_err("missing temperature property\n");
  		return ret;
  	}
-	trip->temperature = prop;
+	trip->temperature = temperature;
 
-	ret = of_property_read_u32(np, "hysteresis", &prop);

drivers/thermal/thermal_of.c static int thermal_of_get_trip_type(struct device_node *np, · line 85

Quoted 10 lines
drivers/thermal/thermal_of.c +2 -1
+	ret = of_property_read_u32(np, "hysteresis", &hysteresis);
  	if (ret < 0) {
  		pr_err("missing hysteresis property\n");
  		return ret;
  	}
-	trip->hysteresis = prop;
+	trip->hysteresis = hysteresis;
 
  	ret = thermal_of_get_trip_type(np, &trip->type);
  	if (ret < 0) {
#2 lore raw
In reply to Rob Herring (Arm)
Quoted 10 lines · Rob Herring (Arm)

The thermal-zone binding defines "temperature" as a signed int32 value and "hysteresis" as an unsigned int32 value. Using helpers with matching types avoids dt_property_check mismatches and preserves the signed interpretation needed for trips below zero.

Read "temperature" with the signed helper and keep "hysteresis" on the unsigned helper using separate typed temporaries before storing them in the trip structure.

Quoted 5 lines
Assisted-by Codex:gpt-5-5
---
 drivers/thermal/thermal_of.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Ping

Quoted 37 lines
drivers/thermal/thermal_of.c +6 -6
index 99085c806a1f..196cb29afae9 100644
@@ -63,22 +63,23 @@ static int thermal_of_get_trip_type(struct device_node *np,
 static int thermal_of_populate_trip(struct device_node *np,
                                    struct thermal_trip *trip)
 {
-       int prop;
+       u32 hysteresis;
+       s32 temperature;
        int ret;
 
-       ret = of_property_read_u32(np, "temperature", &prop);
+       ret = of_property_read_s32(np, "temperature", &temperature);
        if (ret < 0) {
                pr_err("missing temperature property\n");
                return ret;
        }
-       trip->temperature = prop;
+       trip->temperature = temperature;
 
-       ret = of_property_read_u32(np, "hysteresis", &prop);
+       ret = of_property_read_u32(np, "hysteresis", &hysteresis);
        if (ret < 0) {
                pr_err("missing hysteresis property\n");
                return ret;
        }
-       trip->hysteresis = prop;
+       trip->hysteresis = hysteresis;
 
        ret = thermal_of_get_trip_type(np, &trip->type);
        if (ret < 0) {
--

2.53.0

#3 lore raw
In reply to Rob Herring (Arm)
Quoted 5 lines · Rob Herring (Arm)

The thermal-zone binding defines "temperature" as a signed int32 value and "hysteresis" as an unsigned int32 value. Using helpers with matching types avoids dt_property_check mismatches and preserves the signed interpretation needed for trips below zero.

Quoted 7 lines

Read "temperature" with the signed helper and keep "hysteresis" on the unsigned helper using separate typed temporaries before storing them in the trip structure.

Assisted-by Codex:gpt-5-5

---

Applied, thanks

#4 lore raw
In reply to Rob Herring (Arm)
The following commit has been merged into the thermal/linux-next branch of thermal:

The following commit has been merged into the thermal/linux-next branch of thermal:

Commit-ID:     4f6d1a9ea172c22e6c67e2ec06fb0f20e07e7225
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//4f6d1a9ea172c22e6c67e2ec06fb0f20e07e7225
Author:        Rob Herring (Arm) <[email protected]>
AuthorDate:    Fri, 12 Jun 2026 16:50:09 -05:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Mon, 28 Sep 2026 17:54:14 +02:00

thermal: of: Match trip property helper types

The thermal-zone binding defines "temperature" as a signed int32 value and "hysteresis" as an unsigned int32 value. Using helpers with matching types avoids dt_property_check mismatches and preserves the signed interpretation needed for trips below zero.

Read "temperature" with the signed helper and keep "hysteresis" on the unsigned helper using separate typed temporaries before storing them in the trip structure.

---
 drivers/thermal/thermal_of.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/thermal/thermal_of.c +6 -5
index 0217a49..deaae7a 100644
@@ -63,22 +63,23 @@ static int thermal_of_get_trip_type(struct device_node *np,
 static int thermal_of_populate_trip(struct device_node *np,
 				    struct thermal_trip *trip)
 {
-	int prop;
+	u32 hysteresis;
+	s32 temperature;
 	int ret;
 
-	ret = of_property_read_u32(np, "temperature", &prop);
+	ret = of_property_read_s32(np, "temperature", &temperature);
 	if (ret < 0) {
 		pr_err("missing temperature property\n");
 		return ret;
 	}
-	trip->temperature = prop;
+	trip->temperature = temperature;
 
-	ret = of_property_read_u32(np, "hysteresis", &prop);
+	ret = of_property_read_u32(np, "hysteresis", &hysteresis);
 	if (ret < 0) {
 		pr_err("missing hysteresis property\n");
 		return ret;
 	}
-	trip->hysteresis = prop;
+	trip->hysteresis = hysteresis;
 
 	ret = thermal_of_get_trip_type(np, &trip->type);
 	if (ret < 0) {