| Akinobu Mita | 930ae74 | 2006-03-26 01:39:15 -0800 | [diff] [blame] | 1 | #ifndef _ASM_GENERIC_BITOPS_LE_H_ | 
|  | 2 | #define _ASM_GENERIC_BITOPS_LE_H_ | 
|  | 3 |  | 
|  | 4 | #include <asm/types.h> | 
|  | 5 | #include <asm/byteorder.h> | 
|  | 6 |  | 
| Akinobu Mita | 930ae74 | 2006-03-26 01:39:15 -0800 | [diff] [blame] | 7 | #if defined(__LITTLE_ENDIAN) | 
|  | 8 |  | 
| Akinobu Mita | 63ab595 | 2011-03-23 16:41:46 -0700 | [diff] [blame] | 9 | #define BITOP_LE_SWIZZLE	0 | 
| Akinobu Mita | 930ae74 | 2006-03-26 01:39:15 -0800 | [diff] [blame] | 10 |  | 
| Akinobu Mita | a56560b | 2011-03-23 16:41:50 -0700 | [diff] [blame] | 11 | static inline unsigned long find_next_zero_bit_le(const void *addr, | 
|  | 12 | unsigned long size, unsigned long offset) | 
|  | 13 | { | 
|  | 14 | return find_next_zero_bit(addr, size, offset); | 
|  | 15 | } | 
|  | 16 |  | 
|  | 17 | static inline unsigned long find_next_bit_le(const void *addr, | 
|  | 18 | unsigned long size, unsigned long offset) | 
|  | 19 | { | 
|  | 20 | return find_next_bit(addr, size, offset); | 
|  | 21 | } | 
|  | 22 |  | 
|  | 23 | static inline unsigned long find_first_zero_bit_le(const void *addr, | 
|  | 24 | unsigned long size) | 
|  | 25 | { | 
|  | 26 | return find_first_zero_bit(addr, size); | 
|  | 27 | } | 
| Akinobu Mita | 930ae74 | 2006-03-26 01:39:15 -0800 | [diff] [blame] | 28 |  | 
|  | 29 | #elif defined(__BIG_ENDIAN) | 
|  | 30 |  | 
| Akinobu Mita | 63ab595 | 2011-03-23 16:41:46 -0700 | [diff] [blame] | 31 | #define BITOP_LE_SWIZZLE	((BITS_PER_LONG-1) & ~0x7) | 
|  | 32 |  | 
| Akinobu Mita | 19de85e | 2011-05-26 16:26:09 -0700 | [diff] [blame] | 33 | #ifndef find_next_zero_bit_le | 
| Akinobu Mita | a56560b | 2011-03-23 16:41:50 -0700 | [diff] [blame] | 34 | extern unsigned long find_next_zero_bit_le(const void *addr, | 
| Akinobu Mita | 63ab595 | 2011-03-23 16:41:46 -0700 | [diff] [blame] | 35 | unsigned long size, unsigned long offset); | 
| Akinobu Mita | 19de85e | 2011-05-26 16:26:09 -0700 | [diff] [blame] | 36 | #endif | 
|  | 37 |  | 
|  | 38 | #ifndef find_next_bit_le | 
| Akinobu Mita | a56560b | 2011-03-23 16:41:50 -0700 | [diff] [blame] | 39 | extern unsigned long find_next_bit_le(const void *addr, | 
| Akinobu Mita | 63ab595 | 2011-03-23 16:41:46 -0700 | [diff] [blame] | 40 | unsigned long size, unsigned long offset); | 
| Akinobu Mita | 19de85e | 2011-05-26 16:26:09 -0700 | [diff] [blame] | 41 | #endif | 
| Akinobu Mita | 63ab595 | 2011-03-23 16:41:46 -0700 | [diff] [blame] | 42 |  | 
| Akinobu Mita | 19de85e | 2011-05-26 16:26:09 -0700 | [diff] [blame] | 43 | #ifndef find_first_zero_bit_le | 
| Akinobu Mita | c4945b9 | 2011-03-23 16:41:47 -0700 | [diff] [blame] | 44 | #define find_first_zero_bit_le(addr, size) \ | 
|  | 45 | find_next_zero_bit_le((addr), (size), 0) | 
| Akinobu Mita | 19de85e | 2011-05-26 16:26:09 -0700 | [diff] [blame] | 46 | #endif | 
| Akinobu Mita | 63ab595 | 2011-03-23 16:41:46 -0700 | [diff] [blame] | 47 |  | 
|  | 48 | #else | 
|  | 49 | #error "Please fix <asm/byteorder.h>" | 
|  | 50 | #endif | 
|  | 51 |  | 
| Akinobu Mita | a56560b | 2011-03-23 16:41:50 -0700 | [diff] [blame] | 52 | static inline int test_bit_le(int nr, const void *addr) | 
|  | 53 | { | 
|  | 54 | return test_bit(nr ^ BITOP_LE_SWIZZLE, addr); | 
|  | 55 | } | 
| Akinobu Mita | 930ae74 | 2006-03-26 01:39:15 -0800 | [diff] [blame] | 56 |  | 
| Akinobu Mita | a56560b | 2011-03-23 16:41:50 -0700 | [diff] [blame] | 57 | static inline void __set_bit_le(int nr, void *addr) | 
|  | 58 | { | 
|  | 59 | __set_bit(nr ^ BITOP_LE_SWIZZLE, addr); | 
|  | 60 | } | 
| Akinobu Mita | 930ae74 | 2006-03-26 01:39:15 -0800 | [diff] [blame] | 61 |  | 
| Akinobu Mita | a56560b | 2011-03-23 16:41:50 -0700 | [diff] [blame] | 62 | static inline void __clear_bit_le(int nr, void *addr) | 
|  | 63 | { | 
|  | 64 | __clear_bit(nr ^ BITOP_LE_SWIZZLE, addr); | 
|  | 65 | } | 
|  | 66 |  | 
|  | 67 | static inline int test_and_set_bit_le(int nr, void *addr) | 
|  | 68 | { | 
|  | 69 | return test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr); | 
|  | 70 | } | 
|  | 71 |  | 
|  | 72 | static inline int test_and_clear_bit_le(int nr, void *addr) | 
|  | 73 | { | 
|  | 74 | return test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr); | 
|  | 75 | } | 
|  | 76 |  | 
|  | 77 | static inline int __test_and_set_bit_le(int nr, void *addr) | 
|  | 78 | { | 
|  | 79 | return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr); | 
|  | 80 | } | 
|  | 81 |  | 
|  | 82 | static inline int __test_and_clear_bit_le(int nr, void *addr) | 
|  | 83 | { | 
|  | 84 | return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr); | 
|  | 85 | } | 
| Akinobu Mita | 930ae74 | 2006-03-26 01:39:15 -0800 | [diff] [blame] | 86 |  | 
| Akinobu Mita | 930ae74 | 2006-03-26 01:39:15 -0800 | [diff] [blame] | 87 | #endif /* _ASM_GENERIC_BITOPS_LE_H_ */ |