1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_GENERIC_BITOPS_LE_H_
3 #define _ASM_GENERIC_BITOPS_LE_H_
6 #include <asm/byteorder.h>
8 #if defined(__LITTLE_ENDIAN)
10 #define BITOP_LE_SWIZZLE 0
12 static inline unsigned long find_next_zero_bit_le(const void *addr
,
13 unsigned long size
, unsigned long offset
)
15 return find_next_zero_bit(addr
, size
, offset
);
18 static inline unsigned long find_next_bit_le(const void *addr
,
19 unsigned long size
, unsigned long offset
)
21 return find_next_bit(addr
, size
, offset
);
24 static inline unsigned long find_first_zero_bit_le(const void *addr
,
27 return find_first_zero_bit(addr
, size
);
30 #elif defined(__BIG_ENDIAN)
32 #define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)
34 #ifndef find_next_zero_bit_le
35 extern unsigned long find_next_zero_bit_le(const void *addr
,
36 unsigned long size
, unsigned long offset
);
39 #ifndef find_next_bit_le
40 extern unsigned long find_next_bit_le(const void *addr
,
41 unsigned long size
, unsigned long offset
);
44 #ifndef find_first_zero_bit_le
45 #define find_first_zero_bit_le(addr, size) \
46 find_next_zero_bit_le((addr), (size), 0)
50 #error "Please fix <asm/byteorder.h>"
53 static inline int test_bit_le(int nr
, const void *addr
)
55 return test_bit(nr
^ BITOP_LE_SWIZZLE
, addr
);
58 static inline void set_bit_le(int nr
, void *addr
)
60 set_bit(nr
^ BITOP_LE_SWIZZLE
, addr
);
63 static inline void clear_bit_le(int nr
, void *addr
)
65 clear_bit(nr
^ BITOP_LE_SWIZZLE
, addr
);
68 static inline void __set_bit_le(int nr
, void *addr
)
70 __set_bit(nr
^ BITOP_LE_SWIZZLE
, addr
);
73 static inline void __clear_bit_le(int nr
, void *addr
)
75 __clear_bit(nr
^ BITOP_LE_SWIZZLE
, addr
);
78 static inline int test_and_set_bit_le(int nr
, void *addr
)
80 return test_and_set_bit(nr
^ BITOP_LE_SWIZZLE
, addr
);
83 static inline int test_and_clear_bit_le(int nr
, void *addr
)
85 return test_and_clear_bit(nr
^ BITOP_LE_SWIZZLE
, addr
);
88 static inline int __test_and_set_bit_le(int nr
, void *addr
)
90 return __test_and_set_bit(nr
^ BITOP_LE_SWIZZLE
, addr
);
93 static inline int __test_and_clear_bit_le(int nr
, void *addr
)
95 return __test_and_clear_bit(nr
^ BITOP_LE_SWIZZLE
, addr
);
98 #endif /* _ASM_GENERIC_BITOPS_LE_H_ */