diff options
-rw-r--r-- | arch/powerpc/include/asm/bitops.h | 4 | ||||
-rw-r--r-- | include/asm-generic/bitops/le.h | 77 | ||||
-rw-r--r-- | lib/find_next_bit.c | 10 |
3 files changed, 61 insertions, 30 deletions
diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h index 97aacbdd752a..db567ed9212d 100644 --- a/arch/powerpc/include/asm/bitops.h +++ b/arch/powerpc/include/asm/bitops.h | |||
@@ -305,10 +305,10 @@ static __inline__ int test_le_bit(unsigned long nr, | |||
305 | 305 | ||
306 | #define find_first_zero_bit_le(addr, size) \ | 306 | #define find_first_zero_bit_le(addr, size) \ |
307 | find_next_zero_bit_le((addr), (size), 0) | 307 | find_next_zero_bit_le((addr), (size), 0) |
308 | unsigned long find_next_zero_bit_le(const unsigned long *addr, | 308 | unsigned long find_next_zero_bit_le(const void *addr, |
309 | unsigned long size, unsigned long offset); | 309 | unsigned long size, unsigned long offset); |
310 | 310 | ||
311 | unsigned long find_next_bit_le(const unsigned long *addr, | 311 | unsigned long find_next_bit_le(const void *addr, |
312 | unsigned long size, unsigned long offset); | 312 | unsigned long size, unsigned long offset); |
313 | /* Bitmap functions for the ext2 filesystem */ | 313 | /* Bitmap functions for the ext2 filesystem */ |
314 | 314 | ||
diff --git a/include/asm-generic/bitops/le.h b/include/asm-generic/bitops/le.h index 394ac3ebcbde..946a21b1b5dc 100644 --- a/include/asm-generic/bitops/le.h +++ b/include/asm-generic/bitops/le.h | |||
@@ -8,20 +8,31 @@ | |||
8 | 8 | ||
9 | #define BITOP_LE_SWIZZLE 0 | 9 | #define BITOP_LE_SWIZZLE 0 |
10 | 10 | ||
11 | #define find_next_zero_bit_le(addr, size, offset) \ | 11 | static inline unsigned long find_next_zero_bit_le(const void *addr, |
12 | find_next_zero_bit(addr, size, offset) | 12 | unsigned long size, unsigned long offset) |
13 | #define find_next_bit_le(addr, size, offset) \ | 13 | { |
14 | find_next_bit(addr, size, offset) | 14 | return find_next_zero_bit(addr, size, offset); |
15 | #define find_first_zero_bit_le(addr, size) \ | 15 | } |
16 | find_first_zero_bit(addr, size) | 16 | |
17 | static inline unsigned long find_next_bit_le(const void *addr, | ||
18 | unsigned long size, unsigned long offset) | ||
19 | { | ||
20 | return find_next_bit(addr, size, offset); | ||
21 | } | ||
22 | |||
23 | static inline unsigned long find_first_zero_bit_le(const void *addr, | ||
24 | unsigned long size) | ||
25 | { | ||
26 | return find_first_zero_bit(addr, size); | ||
27 | } | ||
17 | 28 | ||
18 | #elif defined(__BIG_ENDIAN) | 29 | #elif defined(__BIG_ENDIAN) |
19 | 30 | ||
20 | #define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) | 31 | #define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) |
21 | 32 | ||
22 | extern unsigned long find_next_zero_bit_le(const unsigned long *addr, | 33 | extern unsigned long find_next_zero_bit_le(const void *addr, |
23 | unsigned long size, unsigned long offset); | 34 | unsigned long size, unsigned long offset); |
24 | extern unsigned long find_next_bit_le(const unsigned long *addr, | 35 | extern unsigned long find_next_bit_le(const void *addr, |
25 | unsigned long size, unsigned long offset); | 36 | unsigned long size, unsigned long offset); |
26 | 37 | ||
27 | #define find_first_zero_bit_le(addr, size) \ | 38 | #define find_first_zero_bit_le(addr, size) \ |
@@ -31,21 +42,39 @@ extern unsigned long find_next_bit_le(const unsigned long *addr, | |||
31 | #error "Please fix <asm/byteorder.h>" | 42 | #error "Please fix <asm/byteorder.h>" |
32 | #endif | 43 | #endif |
33 | 44 | ||
34 | #define test_bit_le(nr, addr) \ | 45 | static inline int test_bit_le(int nr, const void *addr) |
35 | test_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | 46 | { |
36 | #define __set_bit_le(nr, addr) \ | 47 | return test_bit(nr ^ BITOP_LE_SWIZZLE, addr); |
37 | __set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | 48 | } |
38 | #define __clear_bit_le(nr, addr) \ | 49 | |
39 | __clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | 50 | static inline void __set_bit_le(int nr, void *addr) |
40 | 51 | { | |
41 | #define test_and_set_bit_le(nr, addr) \ | 52 | __set_bit(nr ^ BITOP_LE_SWIZZLE, addr); |
42 | test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | 53 | } |
43 | #define test_and_clear_bit_le(nr, addr) \ | 54 | |
44 | test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | 55 | static inline void __clear_bit_le(int nr, void *addr) |
45 | 56 | { | |
46 | #define __test_and_set_bit_le(nr, addr) \ | 57 | __clear_bit(nr ^ BITOP_LE_SWIZZLE, addr); |
47 | __test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | 58 | } |
48 | #define __test_and_clear_bit_le(nr, addr) \ | 59 | |
49 | __test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | 60 | static inline int test_and_set_bit_le(int nr, void *addr) |
61 | { | ||
62 | return test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr); | ||
63 | } | ||
64 | |||
65 | static inline int test_and_clear_bit_le(int nr, void *addr) | ||
66 | { | ||
67 | return test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr); | ||
68 | } | ||
69 | |||
70 | static inline int __test_and_set_bit_le(int nr, void *addr) | ||
71 | { | ||
72 | return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr); | ||
73 | } | ||
74 | |||
75 | static inline int __test_and_clear_bit_le(int nr, void *addr) | ||
76 | { | ||
77 | return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr); | ||
78 | } | ||
50 | 79 | ||
51 | #endif /* _ASM_GENERIC_BITOPS_LE_H_ */ | 80 | #endif /* _ASM_GENERIC_BITOPS_LE_H_ */ |
diff --git a/lib/find_next_bit.c b/lib/find_next_bit.c index c093ba988003..7667c3d907d3 100644 --- a/lib/find_next_bit.c +++ b/lib/find_next_bit.c | |||
@@ -185,15 +185,16 @@ static inline unsigned long ext2_swab(const unsigned long y) | |||
185 | #endif | 185 | #endif |
186 | } | 186 | } |
187 | 187 | ||
188 | unsigned long find_next_zero_bit_le(const unsigned long *addr, unsigned | 188 | unsigned long find_next_zero_bit_le(const void *addr, unsigned |
189 | long size, unsigned long offset) | 189 | long size, unsigned long offset) |
190 | { | 190 | { |
191 | const unsigned long *p = addr + BITOP_WORD(offset); | 191 | const unsigned long *p = addr; |
192 | unsigned long result = offset & ~(BITS_PER_LONG - 1); | 192 | unsigned long result = offset & ~(BITS_PER_LONG - 1); |
193 | unsigned long tmp; | 193 | unsigned long tmp; |
194 | 194 | ||
195 | if (offset >= size) | 195 | if (offset >= size) |
196 | return size; | 196 | return size; |
197 | p += BITOP_WORD(offset); | ||
197 | size -= result; | 198 | size -= result; |
198 | offset &= (BITS_PER_LONG - 1UL); | 199 | offset &= (BITS_PER_LONG - 1UL); |
199 | if (offset) { | 200 | if (offset) { |
@@ -228,15 +229,16 @@ found_middle_swap: | |||
228 | } | 229 | } |
229 | EXPORT_SYMBOL(find_next_zero_bit_le); | 230 | EXPORT_SYMBOL(find_next_zero_bit_le); |
230 | 231 | ||
231 | unsigned long find_next_bit_le(const unsigned long *addr, unsigned | 232 | unsigned long find_next_bit_le(const void *addr, unsigned |
232 | long size, unsigned long offset) | 233 | long size, unsigned long offset) |
233 | { | 234 | { |
234 | const unsigned long *p = addr + BITOP_WORD(offset); | 235 | const unsigned long *p = addr; |
235 | unsigned long result = offset & ~(BITS_PER_LONG - 1); | 236 | unsigned long result = offset & ~(BITS_PER_LONG - 1); |
236 | unsigned long tmp; | 237 | unsigned long tmp; |
237 | 238 | ||
238 | if (offset >= size) | 239 | if (offset >= size) |
239 | return size; | 240 | return size; |
241 | p += BITOP_WORD(offset); | ||
240 | size -= result; | 242 | size -= result; |
241 | offset &= (BITS_PER_LONG - 1UL); | 243 | offset &= (BITS_PER_LONG - 1UL); |
242 | if (offset) { | 244 | if (offset) { |