dt-bindings: thermal: Use signed integers for coefficients
Subsystems (2)
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.
--- Documentation/devicetree/bindings/thermal/thermal-zones.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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.
Signature · 1 line
2.43.0
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")Signed-off-by Daniel Lezcano <[email protected]>--- Documentation/devicetree/bindings/thermal/thermal-zones.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/devicetree/bindings/thermal/thermal-zones.yaml +0
-0
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
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")Signed-off-by Daniel Lezcano <[email protected]>---
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@@ -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.Reviewed-by Lukasz Luba <[email protected]>
Thanks for the review
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")Signed-off-by Daniel Lezcano <[email protected]>--- 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
Rob Herring
maintainerQuoted 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")Signed-off-by Daniel Lezcano <[email protected]>--- Documentation/devicetree/bindings/thermal/thermal-zones.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 5 lines
drivers/thermal/thermal_of.cstill uses u32. Maybe we should haveof_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