diff options
Diffstat (limited to 'include/asm-powerpc')
-rw-r--r-- | include/asm-powerpc/bitops.h | 21 | ||||
-rw-r--r-- | include/asm-powerpc/page_32.h | 10 |
2 files changed, 21 insertions, 10 deletions
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 | ||