]> git.itanic.dy.fi Git - linux-stable/commit
hwmon: (f71882fg) Fix negative temperature
authorJi-Ze Hong (Peter Hong) <hpeter@gmail.com>
Mon, 18 Apr 2022 09:07:06 +0000 (17:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 May 2022 08:23:45 +0000 (10:23 +0200)
commit5ecaaaeb2c767ea18c4dc77055f50d066c62c5b5
tree3da0d3af09d337065f14a410e8f6c995fca80cd6
parent88091c0275b2eed5ad24a444b58e1545abaca859
hwmon: (f71882fg) Fix negative temperature

[ Upstream commit 4aaaaf0f279836f06d3b9d0ffeec7a1e1a04ceef ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hwmon/f71882fg.c