aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic/page.h
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2005-09-03 18:54:30 -0400
committerLinus Torvalds <torvalds@evo.osdl.org>2005-09-05 03:05:39 -0400
commitfd4fd5aac1282825195c6816ed40a2a6d42db5bf (patch)
tree5908cf4c88a7c9d69ea7bdc1c354d51b6ff47f86 /include/asm-generic/page.h
parent28ae55c98e4d16eac9a05a8a259d7763ef3aeb18 (diff)
[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 <sfr@canb.auug.org.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-generic/page.h')
-rw-r--r--include/asm-generic/page.h26
1 files changed, 26 insertions, 0 deletions
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 @@
1#ifndef _ASM_GENERIC_PAGE_H
2#define _ASM_GENERIC_PAGE_H
3
4#ifdef __KERNEL__
5#ifndef __ASSEMBLY__
6
7#include <linux/compiler.h>
8
9/* Pure 2^n version of get_order */
10static __inline__ __attribute_const__ int get_order(unsigned long size)
11{
12 int order;
13
14 size = (size - 1) >> (PAGE_SHIFT - 1);
15 order = -1;
16 do {
17 size >>= 1;
18 order++;
19 } while (size);
20 return order;
21}
22
23#endif /* __ASSEMBLY__ */
24#endif /* __KERNEL__ */
25
26#endif /* _ASM_GENERIC_PAGE_H */