Skip to content

Commit 4aaaaf0

Browse files
hpetergroeck
authored andcommitted
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>
1 parent 4d0d5c3 commit 4aaaaf0

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/hwmon/f71882fg.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,8 +1578,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
15781578
temp *= 125;
15791579
if (sign)
15801580
temp -= 128000;
1581-
} else
1582-
temp = data->temp[nr] * 1000;
1581+
} else {
1582+
temp = ((s8)data->temp[nr]) * 1000;
1583+
}
15831584

15841585
return sprintf(buf, "%d\n", temp);
15851586
}

0 commit comments

Comments
 (0)