diff options
author | Ji-Ze Hong (Peter Hong) <hpeter@gmail.com> | 2022-04-18 12:07:06 +0300 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2022-04-18 18:15:07 +0300 |
commit | 4aaaaf0f279836f06d3b9d0ffeec7a1e1a04ceef (patch) | |
tree | 09d662d70e6e40143b0d6f8eed98c1b54185fb6c /drivers/hwmon | |
parent | 4d0d5c352303a318925ceb84a86818761aa6586b (diff) | |
download | linux-4aaaaf0f279836f06d3b9d0ffeec7a1e1a04ceef.tar.xz |
hwmon: (f71882fg) Fix negative temperature
All temperature of Fintek superio hwmonitor that using 1-byte reg will use
2's complement.
In show_temp()
temp = data->temp[nr] * 1000;
When data->temp[nr] read as 255, it indicate -1C, but this code will report
255C to userspace. It'll be ok when change to:
temp = ((s8)data->temp[nr]) * 1000;
Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
Link: https://lore.kernel.org/r/20220418090706.6339-1-hpeter+linux_kernel@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/f71882fg.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index 938a8b9ec70d..6830e029995d 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c @@ -1578,8 +1578,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, temp *= 125; if (sign) temp -= 128000; - } else - temp = data->temp[nr] * 1000; + } else { + temp = ((s8)data->temp[nr]) * 1000; + } return sprintf(buf, "%d\n", temp); } |