Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull a hwmon fix from Guenter Roeck:
"One patch, fixing DIV_ROUND_CLOSEST to support negative dividends.

While the changes are not in the drivers/hwmon directory, the problem
primarily affects hwmon drivers, and it makes sense to push the patch
through the hwmon tree."

* tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
linux/kernel.h: Fix DIV_ROUND_CLOSEST to support negative dividends

+10 -2
+10 -2
include/linux/kernel.h
··· 82 82 __x - (__x % (y)); \ 83 83 } \ 84 84 ) 85 + 86 + /* 87 + * Divide positive or negative dividend by positive divisor and round 88 + * to closest integer. Result is undefined for negative divisors. 89 + */ 85 90 #define DIV_ROUND_CLOSEST(x, divisor)( \ 86 91 { \ 87 - typeof(divisor) __divisor = divisor; \ 88 - (((x) + ((__divisor) / 2)) / (__divisor)); \ 92 + typeof(x) __x = x; \ 93 + typeof(divisor) __d = divisor; \ 94 + (((typeof(x))-1) >= 0 || (__x) >= 0) ? \ 95 + (((__x) + ((__d) / 2)) / (__d)) : \ 96 + (((__x) - ((__d) / 2)) / (__d)); \ 89 97 } \ 90 98 ) 91 99