Skip to content

Commit 6b8ecb8

Browse files
committed
bitops: move find_bit_*_le functions from le.h to find.h
It's convenient to have all find_bit declarations in one place. Signed-off-by: Yury Norov <[email protected]> Tested-by: Wolfram Sang <[email protected]>
1 parent b7ec62d commit 6b8ecb8

File tree

2 files changed

+69
-64
lines changed

2 files changed

+69
-64
lines changed

include/asm-generic/bitops/find.h

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,73 @@ extern unsigned long find_next_clump8(unsigned long *clump,
190190
#define find_first_clump8(clump, bits, size) \
191191
find_next_clump8((clump), (bits), (size), 0)
192192

193+
#if defined(__LITTLE_ENDIAN)
194+
195+
static inline unsigned long find_next_zero_bit_le(const void *addr,
196+
unsigned long size, unsigned long offset)
197+
{
198+
return find_next_zero_bit(addr, size, offset);
199+
}
200+
201+
static inline unsigned long find_next_bit_le(const void *addr,
202+
unsigned long size, unsigned long offset)
203+
{
204+
return find_next_bit(addr, size, offset);
205+
}
206+
207+
static inline unsigned long find_first_zero_bit_le(const void *addr,
208+
unsigned long size)
209+
{
210+
return find_first_zero_bit(addr, size);
211+
}
212+
213+
#elif defined(__BIG_ENDIAN)
214+
215+
#ifndef find_next_zero_bit_le
216+
static inline
217+
unsigned long find_next_zero_bit_le(const void *addr, unsigned
218+
long size, unsigned long offset)
219+
{
220+
if (small_const_nbits(size)) {
221+
unsigned long val = *(const unsigned long *)addr;
222+
223+
if (unlikely(offset >= size))
224+
return size;
225+
226+
val = swab(val) | ~GENMASK(size - 1, offset);
227+
return val == ~0UL ? size : ffz(val);
228+
}
229+
230+
return _find_next_bit(addr, NULL, size, offset, ~0UL, 1);
231+
}
232+
#endif
233+
234+
#ifndef find_next_bit_le
235+
static inline
236+
unsigned long find_next_bit_le(const void *addr, unsigned
237+
long size, unsigned long offset)
238+
{
239+
if (small_const_nbits(size)) {
240+
unsigned long val = *(const unsigned long *)addr;
241+
242+
if (unlikely(offset >= size))
243+
return size;
244+
245+
val = swab(val) & GENMASK(size - 1, offset);
246+
return val ? __ffs(val) : size;
247+
}
248+
249+
return _find_next_bit(addr, NULL, size, offset, 0UL, 1);
250+
}
251+
#endif
252+
253+
#ifndef find_first_zero_bit_le
254+
#define find_first_zero_bit_le(addr, size) \
255+
find_next_zero_bit_le((addr), (size), 0)
256+
#endif
257+
258+
#else
259+
#error "Please fix <asm/byteorder.h>"
260+
#endif
261+
193262
#endif /*_ASM_GENERIC_BITOPS_FIND_H_ */

include/asm-generic/bitops/le.h

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,19 @@
22
#ifndef _ASM_GENERIC_BITOPS_LE_H_
33
#define _ASM_GENERIC_BITOPS_LE_H_
44

5-
#include <asm-generic/bitops/find.h>
65
#include <asm/types.h>
76
#include <asm/byteorder.h>
8-
#include <linux/swab.h>
97

108
#if defined(__LITTLE_ENDIAN)
119

1210
#define BITOP_LE_SWIZZLE 0
1311

14-
static 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-
20-
static 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-
26-
static 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-
3212
#elif defined(__BIG_ENDIAN)
3313

3414
#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)
3515

36-
#ifndef find_next_zero_bit_le
37-
static inline
38-
unsigned 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
56-
static inline
57-
unsigned 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-
}
7216
#endif
7317

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
8218

8319
static inline int test_bit_le(int nr, const void *addr)
8420
{

0 commit comments

Comments
 (0)