Linux Audio

Check our new training course

Real-Time Linux with PREEMPT_RT training

Feb 18-20, 2025
Register
Loading...
v5.4
 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
12static inline unsigned long find_next_zero_bit_le(const void *addr,
13		unsigned long size, unsigned long offset)
14{
15	return find_next_zero_bit(addr, size, offset);
16}
17
18static inline unsigned long find_next_bit_le(const void *addr,
19		unsigned long size, unsigned long offset)
20{
21	return find_next_bit(addr, size, offset);
22}
23
24static inline unsigned long find_first_zero_bit_le(const void *addr,
25		unsigned long size)
26{
27	return find_first_zero_bit(addr, size);
28}
29
30#elif defined(__BIG_ENDIAN)
31
32#define BITOP_LE_SWIZZLE	((BITS_PER_LONG-1) & ~0x7)
33
34#ifndef find_next_zero_bit_le
35extern unsigned long find_next_zero_bit_le(const void *addr,
36		unsigned long size, unsigned long offset);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37#endif
38
39#ifndef find_next_bit_le
40extern unsigned long find_next_bit_le(const void *addr,
41		unsigned long size, unsigned long offset);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42#endif
43
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)
47#endif
48
49#else
50#error "Please fix <asm/byteorder.h>"
51#endif
52
53static inline int test_bit_le(int nr, const void *addr)
54{
55	return test_bit(nr ^ BITOP_LE_SWIZZLE, addr);
56}
57
58static inline void set_bit_le(int nr, void *addr)
59{
60	set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
61}
62
63static inline void clear_bit_le(int nr, void *addr)
64{
65	clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
66}
67
68static inline void __set_bit_le(int nr, void *addr)
69{
70	__set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
71}
72
73static inline void __clear_bit_le(int nr, void *addr)
74{
75	__clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
76}
77
78static inline int test_and_set_bit_le(int nr, void *addr)
79{
80	return test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
81}
82
83static inline int test_and_clear_bit_le(int nr, void *addr)
84{
85	return test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
86}
87
88static inline int __test_and_set_bit_le(int nr, void *addr)
89{
90	return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
91}
92
93static inline int __test_and_clear_bit_le(int nr, void *addr)
94{
95	return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
96}
97
98#endif /* _ASM_GENERIC_BITOPS_LE_H_ */
v5.14.15
  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-generic/bitops/find.h>
  6#include <asm/types.h>
  7#include <asm/byteorder.h>
  8#include <linux/swab.h>
  9
 10#if defined(__LITTLE_ENDIAN)
 11
 12#define BITOP_LE_SWIZZLE	0
 13
 14static inline unsigned long find_next_zero_bit_le(const void *addr,
 15		unsigned long size, unsigned long offset)
 16{
 17	return find_next_zero_bit(addr, size, offset);
 18}
 19
 20static inline unsigned long find_next_bit_le(const void *addr,
 21		unsigned long size, unsigned long offset)
 22{
 23	return find_next_bit(addr, size, offset);
 24}
 25
 26static inline unsigned long find_first_zero_bit_le(const void *addr,
 27		unsigned long size)
 28{
 29	return find_first_zero_bit(addr, size);
 30}
 31
 32#elif defined(__BIG_ENDIAN)
 33
 34#define BITOP_LE_SWIZZLE	((BITS_PER_LONG-1) & ~0x7)
 35
 36#ifndef find_next_zero_bit_le
 37static inline
 38unsigned long find_next_zero_bit_le(const void *addr, unsigned
 39		long size, unsigned long offset)
 40{
 41	if (small_const_nbits(size)) {
 42		unsigned long val = *(const unsigned long *)addr;
 43
 44		if (unlikely(offset >= size))
 45			return size;
 46
 47		val = swab(val) | ~GENMASK(size - 1, offset);
 48		return val == ~0UL ? size : ffz(val);
 49	}
 50
 51	return _find_next_bit(addr, NULL, size, offset, ~0UL, 1);
 52}
 53#endif
 54
 55#ifndef find_next_bit_le
 56static inline
 57unsigned long find_next_bit_le(const void *addr, unsigned
 58		long size, unsigned long offset)
 59{
 60	if (small_const_nbits(size)) {
 61		unsigned long val = *(const unsigned long *)addr;
 62
 63		if (unlikely(offset >= size))
 64			return size;
 65
 66		val = swab(val) & GENMASK(size - 1, offset);
 67		return val ? __ffs(val) : size;
 68	}
 69
 70	return _find_next_bit(addr, NULL, size, offset, 0UL, 1);
 71}
 72#endif
 73
 74#ifndef find_first_zero_bit_le
 75#define find_first_zero_bit_le(addr, size) \
 76	find_next_zero_bit_le((addr), (size), 0)
 77#endif
 78
 79#else
 80#error "Please fix <asm/byteorder.h>"
 81#endif
 82
 83static inline int test_bit_le(int nr, const void *addr)
 84{
 85	return test_bit(nr ^ BITOP_LE_SWIZZLE, addr);
 86}
 87
 88static inline void set_bit_le(int nr, void *addr)
 89{
 90	set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
 91}
 92
 93static inline void clear_bit_le(int nr, void *addr)
 94{
 95	clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
 96}
 97
 98static inline void __set_bit_le(int nr, void *addr)
 99{
100	__set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
101}
102
103static inline void __clear_bit_le(int nr, void *addr)
104{
105	__clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
106}
107
108static inline int test_and_set_bit_le(int nr, void *addr)
109{
110	return test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
111}
112
113static inline int test_and_clear_bit_le(int nr, void *addr)
114{
115	return test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
116}
117
118static inline int __test_and_set_bit_le(int nr, void *addr)
119{
120	return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
121}
122
123static inline int __test_and_clear_bit_le(int nr, void *addr)
124{
125	return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
126}
127
128#endif /* _ASM_GENERIC_BITOPS_LE_H_ */