]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
hwmon: (tmp421) fix rounding for negative values
authorPaul Fertser <fercerpav@gmail.com>
Fri, 24 Sep 2021 09:30:11 +0000 (12:30 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 5 Nov 2021 08:12:49 +0000 (09:12 +0100)
commitc36dd1b7c7dbfa0883f00a576f1cd2103271e38b
treef4ef68b871a715811115e0a643a6776204679130
parente70b310342f742b949e4038f375b1e50d99eccc9
hwmon: (tmp421) fix rounding for negative values

BugLink: https://bugs.launchpad.net/bugs/1947888
[ 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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
drivers/hwmon/tmp421.c