Skip to contentSkip to conversation

dt-bindings: thermal: Use signed integers for coefficients

PATCH In review Daniel Lezcano 4 participants 5 messages Nov 3 – Nov 6

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dt-bindings: thermal: Use signed integers for coefficients

The coefficients property describes the coefficients of a linear equation used to derive a thermal zone temperature. Both the slope and the constant offset can be negative, and the thermal core stores them as signed integers.

Existing Device Trees already rely on signed values. OMAP4460 uses an offset of -9301, while OMAP5 uses offsets of -1791 and -2992. Broadcom platforms also use negative slopes. Declaring the property as uint32-array does not represent these values correctly.

Change the property type to int32-array so schema validation decodes the cells as signed 32-bit integers, matching their intended meaning and the thermal implementation. The cell width and binary encoding remain unchanged, preserving compatibility with existing Device Trees.

Fixes 1202a442a31f ("dt-bindings: thermal: Add yaml bindings for thermal zones")
---
 Documentation/devicetree/bindings/thermal/thermal-zones.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/thermal/thermal-zones.yaml +1 -1
index 999ad40a20d5..72e419124f98 100644
@@ -101,7 +101,7 @@ patternProperties:
           thermal zone.
 
       coefficients:
-        $ref: /schemas/types.yaml#/definitions/uint32-array
+        $ref: /schemas/types.yaml#/definitions/int32-array
         description:
           An array of integers containing the coefficients of a linear equation
           that binds all the sensors listed in this thermal zone.
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#1 lore raw

Hi Daniel,

Quoted 9 lines · Daniel Lezcano

The coefficients property describes the coefficients of a linear equation used to derive a thermal zone temperature. Both the slope and the constant offset can be negative, and the thermal core stores them as signed integers.

Existing Device Trees already rely on signed values. OMAP4460 uses an offset of -9301, while OMAP5 uses offsets of -1791 and -2992. Broadcom platforms also use negative slopes. Declaring the property as uint32-array does not represent these values correctly.

This looks like a good argument which was missed back then (that the negative values are possible).

Quoted 18 lines

Change the property type to int32-array so schema validation decodes the cells as signed 32-bit integers, matching their intended meaning and the thermal implementation. The cell width and binary encoding remain unchanged, preserving compatibility with existing Device Trees.

Fixes 1202a442a31f ("dt-bindings: thermal: Add yaml bindings for thermal zones")
---
  Documentation/devicetree/bindings/thermal/thermal-zones.yaml | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/thermal/thermal-zones.yaml +0 -0
index 999ad40a20d5..72e419124f98 100644

Documentation/devicetree/bindings/thermal/thermal-zones.yaml patternProperties: · line 107

Quoted 8 lines
Documentation/devicetree/bindings/thermal/thermal-zones.yaml +1 -1
@@ -101,7 +101,7 @@ patternProperties:
            thermal zone.
 
        coefficients:
-        $ref: /schemas/types.yaml#/definitions/uint32-array
+        $ref: /schemas/types.yaml#/definitions/int32-array
          description:
            An array of integers containing the coefficients of a linear equation
            that binds all the sensors listed in this thermal zone.

Regards,
Lukasz

#2 lore raw

Hi Lukasz,

Quoted 29 lines · Lukasz Luba

Hi Daniel,

Quoted 9 lines · Daniel Lezcano

The coefficients property describes the coefficients of a linear equation used to derive a thermal zone temperature. Both the slope and the constant offset can be negative, and the thermal core stores them as signed integers.

Existing Device Trees already rely on signed values. OMAP4460 uses an offset of -9301, while OMAP5 uses offsets of -1791 and -2992. Broadcom platforms also use negative slopes. Declaring the property as uint32-array does not represent these values correctly.

This looks like a good argument which was missed back then (that the negative values are possible).

Quoted 13 lines

Change the property type to int32-array so schema validation decodes the cells as signed 32-bit integers, matching their intended meaning and the thermal implementation. The cell width and binary encoding remain unchanged, preserving compatibility with existing Device Trees.

Fixes 1202a442a31f ("dt-bindings: thermal: Add yaml bindings for thermal zones")

---
  Documentation/devicetree/bindings/thermal/thermal-zones.yaml | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
Quoted 5 lines
Documentation/devicetree/bindings/thermal/thermal-zones.yaml +0 -0
index 999ad40a20d5..72e419124f98 100644
@@ -101,7 +101,7 @@ patternProperties:
Quoted 7 lines

            thermal zone.
        coefficients:
-        $ref: /schemas/types.yaml#/definitions/uint32-array
+        $ref: /schemas/types.yaml#/definitions/int32-array description:
            An array of integers containing the coefficients of a linear equation that binds all the sensors listed in this thermal zone.

Thanks for the review

Reviewed-by on v1 1/1
#3 lore raw
In reply to Daniel Lezcano
Quoted 16 lines · Daniel Lezcano

The coefficients property describes the coefficients of a linear equation used to derive a thermal zone temperature. Both the slope and the constant offset can be negative, and the thermal core stores them as signed integers.

Existing Device Trees already rely on signed values. OMAP4460 uses an offset of -9301, while OMAP5 uses offsets of -1791 and -2992. Broadcom platforms also use negative slopes. Declaring the property as uint32-array does not represent these values correctly.

Change the property type to int32-array so schema validation decodes the cells as signed 32-bit integers, matching their intended meaning and the thermal implementation. The cell width and binary encoding remain unchanged, preserving compatibility with existing Device Trees.

Quoted 5 lines
Fixes 1202a442a31f ("dt-bindings: thermal: Add yaml bindings for thermal zones")
---
 Documentation/devicetree/bindings/thermal/thermal-zones.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

drivers/thermal/thermal_of.c still uses u32. Maybe we should have of_property_read_s32_array() wrapper so the binding can match the ABI code exactly?

Rob?

Best regards,
Krzysztof

maintainer
#4 lore raw
Quoted 23 lines · Krzysztof Kozlowski
Quoted 16 lines · Daniel Lezcano

The coefficients property describes the coefficients of a linear equation used to derive a thermal zone temperature. Both the slope and the constant offset can be negative, and the thermal core stores them as signed integers.

Existing Device Trees already rely on signed values. OMAP4460 uses an offset of -9301, while OMAP5 uses offsets of -1791 and -2992. Broadcom platforms also use negative slopes. Declaring the property as uint32-array does not represent these values correctly.

Change the property type to int32-array so schema validation decodes the cells as signed 32-bit integers, matching their intended meaning and the thermal implementation. The cell width and binary encoding remain unchanged, preserving compatibility with existing Device Trees.

Quoted 5 lines
Fixes 1202a442a31f ("dt-bindings: thermal: Add yaml bindings for thermal zones")
---
 Documentation/devicetree/bindings/thermal/thermal-zones.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 5 lines

drivers/thermal/thermal_of.c still uses u32. Maybe we should have of_property_read_s32_array() wrapper so the binding can match the ABI code exactly?

Rob?

Yes, please. I did a pass fixing type mismatches so it would be good to not add new ones.

Rob