David Howells wrote:
From: David Howells <[EMAIL PROTECTED]>
Fix get_order() to use ilog2() properly.
Signed-Off-By: David Howells <[EMAIL PROTECTED]>
---
include/asm-generic/page.h | 14 +++++++++++---
include/linux/log2.h | 20 ++++++++++++++++++--
2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h
index b55052c..c37571d 100644
--- a/include/asm-generic/page.h
+++ b/include/asm-generic/page.h
@@ -17,10 +17,18 @@ static inline __attribute__((const))
int __get_order(unsigned long size, int page_shift)
{
#if BITS_PER_LONG == 32 && defined(ARCH_HAS_ILOG2_U32)
- int order = __ilog2_u32(size) - page_shift;
+ int order;
+ if (size <= 1)
+ order = 0;
+ else
+ order = __ilog2_u32(size - 1) + 1 - page_shift;
return order >= 0 ? order : 0;
This seems a lot more complex than it should be.
Assuming page_shift is usually constant, it would seem to make more
sense to do:
if (size <= (1UL << page_shift))
return 0;
else
return __ilog2_u32(size-1)+1-page_shift;
... instead of having *two* conditionals...
-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/