hwmon: (tmp421) fix rounding for negative values
authorPaul Fertser <fercerpav@gmail.com>
Fri, 24 Sep 2021 09:30:11 +0000 (12:30 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 Oct 2021 13:55:53 +0000 (15:55 +0200)
commit5ee40530b0a6eaae24f77c63411bb1216caab0e2
tree19e27a23c771692174f2d56f874148e2fd4f8e82
parent89d96f147d82c74f8ec1e2812695fbf89ec3e7ee
hwmon: (tmp421) fix rounding for negative values

[ Upstream commit 724e8af85854c4d3401313b6dd7d79cf792d8990 ]

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: 9410700b881f ("hwmon: Add driver for Texas Instruments TMP421/422/423 sensor chips")
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Link: https://lore.kernel.org/r/20210924093011.26083-3-fercerpav@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hwmon/tmp421.c