| 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef _ASM_GENERIC_BITOPS_LE_H_ |
| 3 | #define _ASM_GENERIC_BITOPS_LE_H_ |
| 4 | |
| 5 | #include <asm/types.h> |
| 6 | #include <asm/byteorder.h> |
| 7 | |
| 8 | #if defined(__LITTLE_ENDIAN) |
| 9 | |
| 10 | #define BITOP_LE_SWIZZLE 0 |
| 11 | |
| 12 | #elif defined(__BIG_ENDIAN) |
| 13 | |
| 14 | #define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) |
| 15 | |
| 16 | #endif |
| 17 | |
| 18 | |
| 19 | static inline int test_bit_le(int nr, const void *addr) |
| 20 | { |
| 21 | return test_bit(nr ^ BITOP_LE_SWIZZLE, addr); |
| 22 | } |
| 23 | |
| 24 | static inline void set_bit_le(int nr, void *addr) |
| 25 | { |
| 26 | set_bit(nr: nr ^ BITOP_LE_SWIZZLE, addr); |
| 27 | } |
| 28 | |
| 29 | static inline void clear_bit_le(int nr, void *addr) |
| 30 | { |
| 31 | clear_bit(nr: nr ^ BITOP_LE_SWIZZLE, addr); |
| 32 | } |
| 33 | |
| 34 | static inline void __set_bit_le(int nr, void *addr) |
| 35 | { |
| 36 | __set_bit(nr ^ BITOP_LE_SWIZZLE, addr); |
| 37 | } |
| 38 | |
| 39 | static inline void __clear_bit_le(int nr, void *addr) |
| 40 | { |
| 41 | __clear_bit(nr ^ BITOP_LE_SWIZZLE, addr); |
| 42 | } |
| 43 | |
| 44 | static inline int test_and_set_bit_le(int nr, void *addr) |
| 45 | { |
| 46 | return test_and_set_bit(nr: nr ^ BITOP_LE_SWIZZLE, addr); |
| 47 | } |
| 48 | |
| 49 | static inline int test_and_clear_bit_le(int nr, void *addr) |
| 50 | { |
| 51 | return test_and_clear_bit(nr: nr ^ BITOP_LE_SWIZZLE, addr); |
| 52 | } |
| 53 | |
| 54 | static inline int __test_and_set_bit_le(int nr, void *addr) |
| 55 | { |
| 56 | return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr); |
| 57 | } |
| 58 | |
| 59 | static inline int __test_and_clear_bit_le(int nr, void *addr) |
| 60 | { |
| 61 | return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr); |
| 62 | } |
| 63 | |
| 64 | #endif /* _ASM_GENERIC_BITOPS_LE_H_ */ |
| 65 | |