18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_GENERIC_BITOPS_LE_H_
38c2ecf20Sopenharmony_ci#define _ASM_GENERIC_BITOPS_LE_H_
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <asm/types.h>
68c2ecf20Sopenharmony_ci#include <asm/byteorder.h>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#if defined(__LITTLE_ENDIAN)
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#define BITOP_LE_SWIZZLE	0
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cistatic inline unsigned long find_next_zero_bit_le(const void *addr,
138c2ecf20Sopenharmony_ci		unsigned long size, unsigned long offset)
148c2ecf20Sopenharmony_ci{
158c2ecf20Sopenharmony_ci	return find_next_zero_bit(addr, size, offset);
168c2ecf20Sopenharmony_ci}
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_cistatic inline unsigned long find_next_bit_le(const void *addr,
198c2ecf20Sopenharmony_ci		unsigned long size, unsigned long offset)
208c2ecf20Sopenharmony_ci{
218c2ecf20Sopenharmony_ci	return find_next_bit(addr, size, offset);
228c2ecf20Sopenharmony_ci}
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistatic inline unsigned long find_first_zero_bit_le(const void *addr,
258c2ecf20Sopenharmony_ci		unsigned long size)
268c2ecf20Sopenharmony_ci{
278c2ecf20Sopenharmony_ci	return find_first_zero_bit(addr, size);
288c2ecf20Sopenharmony_ci}
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#elif defined(__BIG_ENDIAN)
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define BITOP_LE_SWIZZLE	((BITS_PER_LONG-1) & ~0x7)
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#ifndef find_next_zero_bit_le
358c2ecf20Sopenharmony_ciextern unsigned long find_next_zero_bit_le(const void *addr,
368c2ecf20Sopenharmony_ci		unsigned long size, unsigned long offset);
378c2ecf20Sopenharmony_ci#endif
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#ifndef find_next_bit_le
408c2ecf20Sopenharmony_ciextern unsigned long find_next_bit_le(const void *addr,
418c2ecf20Sopenharmony_ci		unsigned long size, unsigned long offset);
428c2ecf20Sopenharmony_ci#endif
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#ifndef find_first_zero_bit_le
458c2ecf20Sopenharmony_ci#define find_first_zero_bit_le(addr, size) \
468c2ecf20Sopenharmony_ci	find_next_zero_bit_le((addr), (size), 0)
478c2ecf20Sopenharmony_ci#endif
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#else
508c2ecf20Sopenharmony_ci#error "Please fix <asm/byteorder.h>"
518c2ecf20Sopenharmony_ci#endif
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cistatic inline int test_bit_le(int nr, const void *addr)
548c2ecf20Sopenharmony_ci{
558c2ecf20Sopenharmony_ci	return test_bit(nr ^ BITOP_LE_SWIZZLE, addr);
568c2ecf20Sopenharmony_ci}
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_cistatic inline void set_bit_le(int nr, void *addr)
598c2ecf20Sopenharmony_ci{
608c2ecf20Sopenharmony_ci	set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
618c2ecf20Sopenharmony_ci}
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_cistatic inline void clear_bit_le(int nr, void *addr)
648c2ecf20Sopenharmony_ci{
658c2ecf20Sopenharmony_ci	clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
668c2ecf20Sopenharmony_ci}
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_cistatic inline void __set_bit_le(int nr, void *addr)
698c2ecf20Sopenharmony_ci{
708c2ecf20Sopenharmony_ci	__set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
718c2ecf20Sopenharmony_ci}
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_cistatic inline void __clear_bit_le(int nr, void *addr)
748c2ecf20Sopenharmony_ci{
758c2ecf20Sopenharmony_ci	__clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
768c2ecf20Sopenharmony_ci}
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_cistatic inline int test_and_set_bit_le(int nr, void *addr)
798c2ecf20Sopenharmony_ci{
808c2ecf20Sopenharmony_ci	return test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
818c2ecf20Sopenharmony_ci}
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cistatic inline int test_and_clear_bit_le(int nr, void *addr)
848c2ecf20Sopenharmony_ci{
858c2ecf20Sopenharmony_ci	return test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
868c2ecf20Sopenharmony_ci}
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_cistatic inline int __test_and_set_bit_le(int nr, void *addr)
898c2ecf20Sopenharmony_ci{
908c2ecf20Sopenharmony_ci	return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
918c2ecf20Sopenharmony_ci}
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_cistatic inline int __test_and_clear_bit_le(int nr, void *addr)
948c2ecf20Sopenharmony_ci{
958c2ecf20Sopenharmony_ci	return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
968c2ecf20Sopenharmony_ci}
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#endif /* _ASM_GENERIC_BITOPS_LE_H_ */
99