]> git.baikalelectronics.ru Git - 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)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 24 Sep 2021 12:00:53 +0000 (05:00 -0700)
commitd280ba47a3169da0647ee85c6f149adf65dd5807
treec43272ccd3b7381f3d7e3e452171d4f551b820cc
parent12f01a8d9d69dc8d77a5cedc6b15deb0d1ab1a23
hwmon: (tmp421) fix rounding for negative values

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: 49fec4ff7c2b ("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>
drivers/hwmon/tmp421.c