Skip to content

Commit 78d1355

Browse files
Riwen Lugroeck
authored andcommitted
hwmon: (scpi-hwmon) shows the negative temperature properly
The scpi hwmon shows the sub-zero temperature in an unsigned integer, which would confuse the users when the machine works in low temperature environment. This shows the sub-zero temperature in an signed value and users can get it properly from sensors. Signed-off-by: Riwen Lu <[email protected]> Tested-by: Xin Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 7656cd2 commit 78d1355

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/hwmon/scpi-hwmon.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ scpi_show_sensor(struct device *dev, struct device_attribute *attr, char *buf)
9999

100100
scpi_scale_reading(&value, sensor);
101101

102+
/*
103+
* Temperature sensor values are treated as signed values based on
104+
* observation even though that is not explicitly specified, and
105+
* because an unsigned u64 temperature does not really make practical
106+
* sense especially when the temperature is below zero degrees Celsius.
107+
*/
108+
if (sensor->info.class == TEMPERATURE)
109+
return sprintf(buf, "%lld\n", (s64)value);
110+
102111
return sprintf(buf, "%llu\n", value);
103112
}
104113

0 commit comments

Comments
 (0)