diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2011-03-23 19:41:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-23 22:46:13 -0400 |
commit | f6b57e322f85f9d69db15ca112ee33cab33041b8 (patch) | |
tree | b532c0f0088bece8af632ac5273672f79f5cb127 | |
parent | 50b9b475c5b3e6649c22e1d39ab3ced3dbf21758 (diff) |
arm: introduce little-endian bitops
Introduce little-endian bit operations by renaming native ext2 bit
operations. The ext2 and minix bit operations are kept as wrapper macros
using little-endian bit operations to maintain bisectability until the
conversions are finished.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/arm/include/asm/bitops.h | 91 |
1 files changed, 65 insertions, 26 deletions
diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h index af54ed102f5f..0112005f3e9f 100644 --- a/arch/arm/include/asm/bitops.h +++ b/arch/arm/include/asm/bitops.h | |||
@@ -287,41 +287,80 @@ static inline int fls(int x) | |||
287 | #include <asm-generic/bitops/hweight.h> | 287 | #include <asm-generic/bitops/hweight.h> |
288 | #include <asm-generic/bitops/lock.h> | 288 | #include <asm-generic/bitops/lock.h> |
289 | 289 | ||
290 | static inline void __set_bit_le(int nr, void *addr) | ||
291 | { | ||
292 | __set_bit(WORD_BITOFF_TO_LE(nr), addr); | ||
293 | } | ||
294 | |||
295 | static inline void __clear_bit_le(int nr, void *addr) | ||
296 | { | ||
297 | __clear_bit(WORD_BITOFF_TO_LE(nr), addr); | ||
298 | } | ||
299 | |||
300 | static inline int __test_and_set_bit_le(int nr, void *addr) | ||
301 | { | ||
302 | return __test_and_set_bit(WORD_BITOFF_TO_LE(nr), addr); | ||
303 | } | ||
304 | |||
305 | static inline int test_and_set_bit_le(int nr, void *addr) | ||
306 | { | ||
307 | return test_and_set_bit(WORD_BITOFF_TO_LE(nr), addr); | ||
308 | } | ||
309 | |||
310 | static inline int __test_and_clear_bit_le(int nr, void *addr) | ||
311 | { | ||
312 | return __test_and_clear_bit(WORD_BITOFF_TO_LE(nr), addr); | ||
313 | } | ||
314 | |||
315 | static inline int test_and_clear_bit_le(int nr, void *addr) | ||
316 | { | ||
317 | return test_and_clear_bit(WORD_BITOFF_TO_LE(nr), addr); | ||
318 | } | ||
319 | |||
320 | static inline int test_bit_le(int nr, const void *addr) | ||
321 | { | ||
322 | return test_bit(WORD_BITOFF_TO_LE(nr), addr); | ||
323 | } | ||
324 | |||
325 | static inline int find_first_zero_bit_le(const void *p, unsigned size) | ||
326 | { | ||
327 | return _find_first_zero_bit_le(p, size); | ||
328 | } | ||
329 | |||
330 | static inline int find_next_zero_bit_le(const void *p, int size, int offset) | ||
331 | { | ||
332 | return _find_next_zero_bit_le(p, size, offset); | ||
333 | } | ||
334 | |||
335 | static inline int find_next_bit_le(const void *p, int size, int offset) | ||
336 | { | ||
337 | return _find_next_bit_le(p, size, offset); | ||
338 | } | ||
339 | |||
290 | /* | 340 | /* |
291 | * Ext2 is defined to use little-endian byte ordering. | 341 | * Ext2 is defined to use little-endian byte ordering. |
292 | * These do not need to be atomic. | 342 | * These do not need to be atomic. |
293 | */ | 343 | */ |
294 | #define ext2_set_bit(nr,p) \ | 344 | #define ext2_set_bit __test_and_set_bit_le |
295 | __test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) | 345 | #define ext2_set_bit_atomic(lock, nr, p) \ |
296 | #define ext2_set_bit_atomic(lock,nr,p) \ | 346 | test_and_set_bit_le(nr, p) |
297 | test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) | 347 | #define ext2_clear_bit __test_and_clear_bit_le |
298 | #define ext2_clear_bit(nr,p) \ | 348 | #define ext2_clear_bit_atomic(lock, nr, p) \ |
299 | __test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) | 349 | test_and_clear_bit_le(nr, p) |
300 | #define ext2_clear_bit_atomic(lock,nr,p) \ | 350 | #define ext2_test_bit test_bit_le |
301 | test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) | 351 | #define ext2_find_first_zero_bit find_first_zero_bit_le |
302 | #define ext2_test_bit(nr,p) \ | 352 | #define ext2_find_next_zero_bit find_next_zero_bit_le |
303 | test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) | 353 | #define ext2_find_next_bit find_next_bit_le |
304 | #define ext2_find_first_zero_bit(p,sz) \ | ||
305 | _find_first_zero_bit_le(p,sz) | ||
306 | #define ext2_find_next_zero_bit(p,sz,off) \ | ||
307 | _find_next_zero_bit_le(p,sz,off) | ||
308 | #define ext2_find_next_bit(p, sz, off) \ | ||
309 | _find_next_bit_le(p, sz, off) | ||
310 | 354 | ||
311 | /* | 355 | /* |
312 | * Minix is defined to use little-endian byte ordering. | 356 | * Minix is defined to use little-endian byte ordering. |
313 | * These do not need to be atomic. | 357 | * These do not need to be atomic. |
314 | */ | 358 | */ |
315 | #define minix_set_bit(nr,p) \ | 359 | #define minix_set_bit __set_bit_le |
316 | __set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) | 360 | #define minix_test_bit test_bit_le |
317 | #define minix_test_bit(nr,p) \ | 361 | #define minix_test_and_set_bit __test_and_set_bit_le |
318 | test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) | 362 | #define minix_test_and_clear_bit __test_and_clear_bit_le |
319 | #define minix_test_and_set_bit(nr,p) \ | 363 | #define minix_find_first_zero_bit find_first_zero_bit_le |
320 | __test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) | ||
321 | #define minix_test_and_clear_bit(nr,p) \ | ||
322 | __test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) | ||
323 | #define minix_find_first_zero_bit(p,sz) \ | ||
324 | _find_first_zero_bit_le(p,sz) | ||
325 | 364 | ||
326 | #endif /* __KERNEL__ */ | 365 | #endif /* __KERNEL__ */ |
327 | 366 | ||