From fd4fd5aac1282825195c6816ed40a2a6d42db5bf Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Sat, 3 Sep 2005 15:54:30 -0700 Subject: [PATCH] mm: consolidate get_order Someone mentioned that almost all the architectures used basically the same implementation of get_order. This patch consolidates them into asm-generic/page.h and includes that in the appropriate places. The exceptions are ia64 and ppc which have their own (presumably optimised) versions. Signed-off-by: Stephen Rothwell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-generic/page.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 include/asm-generic/page.h (limited to 'include/asm-generic') diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h new file mode 100644 index 000000000000..a96b5d986b6e --- /dev/null +++ b/include/asm-generic/page.h @@ -0,0 +1,26 @@ +#ifndef _ASM_GENERIC_PAGE_H +#define _ASM_GENERIC_PAGE_H + +#ifdef __KERNEL__ +#ifndef __ASSEMBLY__ + +#include + +/* Pure 2^n version of get_order */ +static __inline__ __attribute_const__ int get_order(unsigned long size) +{ + int order; + + size = (size - 1) >> (PAGE_SHIFT - 1); + order = -1; + do { + size >>= 1; + order++; + } while (size); + return order; +} + +#endif /* __ASSEMBLY__ */ +#endif /* __KERNEL__ */ + +#endif /* _ASM_GENERIC_PAGE_H */ -- cgit v1.2.3