Commit 1a06a52e authored by Rolf Eike Beer's avatar Rolf Eike Beer Committed by Linus Torvalds

Fix roundup_pow_of_two(1)

1 is a power of two, therefore roundup_pow_of_two(1) should return 1. It does
in case the argument is a variable but in case it's a constant it behaves
wrong and returns 0. Probably nobody ever did it so this was never noticed.
Signed-off-by: default avatarRolf Eike Beer <eike-kernel@sf-tec.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 18963c01
...@@ -159,7 +159,7 @@ unsigned long __roundup_pow_of_two(unsigned long n) ...@@ -159,7 +159,7 @@ unsigned long __roundup_pow_of_two(unsigned long n)
#define roundup_pow_of_two(n) \ #define roundup_pow_of_two(n) \
( \ ( \
__builtin_constant_p(n) ? ( \ __builtin_constant_p(n) ? ( \
(n == 1) ? 0 : \ (n == 1) ? 1 : \
(1UL << (ilog2((n) - 1) + 1)) \ (1UL << (ilog2((n) - 1) + 1)) \
) : \ ) : \
__roundup_pow_of_two(n) \ __roundup_pow_of_two(n) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment