diff options
-rw-r--r-- | arch/powerpc/Kconfig | 4 | ||||
-rw-r--r-- | include/asm-powerpc/bitops.h | 21 | ||||
-rw-r--r-- | include/asm-powerpc/page_32.h | 10 |
3 files changed, 23 insertions, 12 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 97c7a212cdda..56c3c4065eb0 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
@@ -43,11 +43,11 @@ config RWSEM_XCHGADD_ALGORITHM | |||
43 | 43 | ||
44 | config ARCH_HAS_ILOG2_U32 | 44 | config ARCH_HAS_ILOG2_U32 |
45 | bool | 45 | bool |
46 | default n | 46 | default y |
47 | 47 | ||
48 | config ARCH_HAS_ILOG2_U64 | 48 | config ARCH_HAS_ILOG2_U64 |
49 | bool | 49 | bool |
50 | default n | 50 | default y if 64BIT |
51 | 51 | ||
52 | config GENERIC_HWEIGHT | 52 | config GENERIC_HWEIGHT |
53 | bool | 53 | bool |
diff --git a/include/asm-powerpc/bitops.h b/include/asm-powerpc/bitops.h index c341063d0804..0288144ea024 100644 --- a/include/asm-powerpc/bitops.h +++ b/include/asm-powerpc/bitops.h | |||
@@ -190,7 +190,8 @@ static __inline__ void set_bits(unsigned long mask, unsigned long *addr) | |||
190 | * Return the zero-based bit position (LE, not IBM bit numbering) of | 190 | * Return the zero-based bit position (LE, not IBM bit numbering) of |
191 | * the most significant 1-bit in a double word. | 191 | * the most significant 1-bit in a double word. |
192 | */ | 192 | */ |
193 | static __inline__ int __ilog2(unsigned long x) | 193 | static __inline__ __attribute__((const)) |
194 | int __ilog2(unsigned long x) | ||
194 | { | 195 | { |
195 | int lz; | 196 | int lz; |
196 | 197 | ||
@@ -198,6 +199,24 @@ static __inline__ int __ilog2(unsigned long x) | |||
198 | return BITS_PER_LONG - 1 - lz; | 199 | return BITS_PER_LONG - 1 - lz; |
199 | } | 200 | } |
200 | 201 | ||
202 | static inline __attribute__((const)) | ||
203 | int __ilog2_u32(u32 n) | ||
204 | { | ||
205 | int bit; | ||
206 | asm ("cntlzw %0,%1" : "=r" (bit) : "r" (n)); | ||
207 | return 31 - bit; | ||
208 | } | ||
209 | |||
210 | #ifdef __powerpc64__ | ||
211 | static inline __attribute__((const)) | ||
212 | int __ilog2_u64(u32 n) | ||
213 | { | ||
214 | int bit; | ||
215 | asm ("cntlzd %0,%1" : "=r" (bit) : "r" (n)); | ||
216 | return 63 - bit; | ||
217 | } | ||
218 | #endif | ||
219 | |||
201 | /* | 220 | /* |
202 | * Determines the bit position of the least significant 0 bit in the | 221 | * Determines the bit position of the least significant 0 bit in the |
203 | * specified double word. The returned bit position will be | 222 | * specified double word. The returned bit position will be |
diff --git a/include/asm-powerpc/page_32.h b/include/asm-powerpc/page_32.h index 2677bad70f40..07f6d3cf5e5a 100644 --- a/include/asm-powerpc/page_32.h +++ b/include/asm-powerpc/page_32.h | |||
@@ -26,15 +26,7 @@ extern void clear_pages(void *page, int order); | |||
26 | static inline void clear_page(void *page) { clear_pages(page, 0); } | 26 | static inline void clear_page(void *page) { clear_pages(page, 0); } |
27 | extern void copy_page(void *to, void *from); | 27 | extern void copy_page(void *to, void *from); |
28 | 28 | ||
29 | /* Pure 2^n version of get_order */ | 29 | #include <asm-generic/page.h> |
30 | extern __inline__ int get_order(unsigned long size) | ||
31 | { | ||
32 | int lz; | ||
33 | |||
34 | size = (size-1) >> PAGE_SHIFT; | ||
35 | asm ("cntlzw %0,%1" : "=r" (lz) : "r" (size)); | ||
36 | return 32 - lz; | ||
37 | } | ||
38 | 30 | ||
39 | #endif /* __ASSEMBLY__ */ | 31 | #endif /* __ASSEMBLY__ */ |
40 | 32 | ||