]> git.baikalelectronics.ru Git - kernel.git/commit
linux/kernel.h: Fix DIV_ROUND_CLOSEST to support negative dividends
authorGuenter Roeck <linux@roeck-us.net>
Sat, 25 Aug 2012 00:25:01 +0000 (17:25 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Sun, 2 Sep 2012 01:58:09 +0000 (18:58 -0700)
commitbb2781d08272af596c1797da8953ac10744947a6
tree814c4ba720911beba197b610d4bd4559a26c3e96
parent02230fc23eac9191110a1143d3da979dc7ed2a68
linux/kernel.h: Fix DIV_ROUND_CLOSEST to support negative dividends

DIV_ROUND_CLOSEST returns a bad result for negative dividends:
DIV_ROUND_CLOSEST(-2, 2) = 0

Most of the time this does not matter. However, in the hardware monitoring
subsystem, DIV_ROUND_CLOSEST is sometimes used on integers which can be
negative (such as temperatures).

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
include/linux/kernel.h