diff options
-rw-r--r-- | lib/int_sqrt.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/int_sqrt.c b/lib/int_sqrt.c index 036c96781ea8..67bb300b5b46 100644 --- a/lib/int_sqrt.c +++ b/lib/int_sqrt.c | |||
@@ -8,6 +8,7 @@ | |||
8 | 8 | ||
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/export.h> | 10 | #include <linux/export.h> |
11 | #include <linux/bitops.h> | ||
11 | 12 | ||
12 | /** | 13 | /** |
13 | * int_sqrt - rough approximation to sqrt | 14 | * int_sqrt - rough approximation to sqrt |
@@ -22,10 +23,7 @@ unsigned long int_sqrt(unsigned long x) | |||
22 | if (x <= 1) | 23 | if (x <= 1) |
23 | return x; | 24 | return x; |
24 | 25 | ||
25 | m = 1UL << (BITS_PER_LONG - 2); | 26 | m = 1UL << (__fls(x) & ~1UL); |
26 | while (m > x) | ||
27 | m >>= 2; | ||
28 | |||
29 | while (m != 0) { | 27 | while (m != 0) { |
30 | b = y + m; | 28 | b = y + m; |
31 | y >>= 1; | 29 | y >>= 1; |