Commit cacceb6a authored by Paul Fertser's avatar Paul Fertser Committed by Zheng Zengkai
Browse files

hwmon: (tmp421) fix rounding for negative values

stable inclusion
from stable-5.10.71
commit 5ee40530b0a6eaae24f77c63411bb1216caab0e2
bugzilla: 182981 https://gitee.com/openeuler/kernel/issues/I4I3KD

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=5ee40530b0a6eaae24f77c63411bb1216caab0e2



--------------------------------

[ Upstream commit 724e8af8 ]

Old code produces -24999 for 0b1110011100000000 input in standard format due to
always rounding up rather than "away from zero".

Use the common macro for division, unify and simplify the conversion code along
the way.

Fixes: 9410700b ("hwmon: Add driver for Texas Instruments TMP421/422/423 sensor chips")
Signed-off-by: default avatarPaul Fertser <fercerpav@gmail.com>
Link: https://lore.kernel.org/r/20210924093011.26083-3-fercerpav@gmail.com


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarChen Jun <chenjun102@huawei.com>
Acked-by: default avatarWeilong Chen <chenweilong@huawei.com>

Signed-off-by: default avatarChen Jun <chenjun102@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent b30c78e5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment