From: David Howells <dhowells@xxxxxxxxxx>
Fix get_order() to use ilog2() properly.
Signed-Off-By: David Howells <dhowells@xxxxxxxxxx>
---
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;