summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorNiklas Söderlund2017-02-25 00:01:01 +0100
committerLinus Torvalds2017-02-25 02:46:57 +0100
commit4f5901f5a6724f4ed1641e4a94978c5039a1f8c4 (patch)
treeec5f0c5a8485b040defd3a2247656b6524645f07 /usr
parentlib/find_bit.c: micro-optimise find_next_*_bit (diff)
downloadkernel-qcow2-linux-4f5901f5a6724f4ed1641e4a94978c5039a1f8c4.tar.gz
kernel-qcow2-linux-4f5901f5a6724f4ed1641e4a94978c5039a1f8c4.tar.xz
kernel-qcow2-linux-4f5901f5a6724f4ed1641e4a94978c5039a1f8c4.zip
linux/kernel.h: fix DIV_ROUND_CLOSEST to support negative divisors
While working on a thermal driver I encounter a scenario where the divisor could be negative, instead of adding local code to handle this I though I first try to add support for this in DIV_ROUND_CLOSEST. Add support to DIV_ROUND_CLOSEST for negative divisors if both dividend and divisor variable types are signed. This should not alter current behavior for users of the macro as previously negative divisors where not supported. Before: DIV_ROUND_CLOSEST( 59, 4) = 15 DIV_ROUND_CLOSEST( 59, -4) = -14 DIV_ROUND_CLOSEST( -59, 4) = -15 DIV_ROUND_CLOSEST( -59, -4) = 14 After: DIV_ROUND_CLOSEST( 59, 4) = 15 DIV_ROUND_CLOSEST( 59, -4) = -15 DIV_ROUND_CLOSEST( -59, 4) = -15 DIV_ROUND_CLOSEST( -59, -4) = 15 [akpm@linux-foundation.org: fix comment, per Guenter] Link: http://lkml.kernel.org/r/20161222102217.29011-1-niklas.soderlund+renesas@ragnatech.se Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'usr')
0 files changed, 0 insertions, 0 deletions