aboutsummaryrefslogtreecommitdiffstats
path: root/lib/find_next_bit.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/find_next_bit.c')
-rw-r--r--lib/find_next_bit.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/lib/find_next_bit.c b/lib/find_next_bit.c
index 24c59ded47a0..4bd75a73ba00 100644
--- a/lib/find_next_bit.c
+++ b/lib/find_next_bit.c
@@ -16,7 +16,7 @@
16 16
17#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) 17#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG)
18 18
19#ifdef CONFIG_GENERIC_FIND_NEXT_BIT 19#ifndef find_next_bit
20/* 20/*
21 * Find the next set bit in a memory region. 21 * Find the next set bit in a memory region.
22 */ 22 */
@@ -59,7 +59,9 @@ found_middle:
59 return result + __ffs(tmp); 59 return result + __ffs(tmp);
60} 60}
61EXPORT_SYMBOL(find_next_bit); 61EXPORT_SYMBOL(find_next_bit);
62#endif
62 63
64#ifndef find_next_zero_bit
63/* 65/*
64 * This implementation of find_{first,next}_zero_bit was stolen from 66 * This implementation of find_{first,next}_zero_bit was stolen from
65 * Linus' asm-alpha/bitops.h. 67 * Linus' asm-alpha/bitops.h.
@@ -103,9 +105,9 @@ found_middle:
103 return result + ffz(tmp); 105 return result + ffz(tmp);
104} 106}
105EXPORT_SYMBOL(find_next_zero_bit); 107EXPORT_SYMBOL(find_next_zero_bit);
106#endif /* CONFIG_GENERIC_FIND_NEXT_BIT */ 108#endif
107 109
108#ifdef CONFIG_GENERIC_FIND_FIRST_BIT 110#ifndef find_first_bit
109/* 111/*
110 * Find the first set bit in a memory region. 112 * Find the first set bit in a memory region.
111 */ 113 */
@@ -131,7 +133,9 @@ found:
131 return result + __ffs(tmp); 133 return result + __ffs(tmp);
132} 134}
133EXPORT_SYMBOL(find_first_bit); 135EXPORT_SYMBOL(find_first_bit);
136#endif
134 137
138#ifndef find_first_zero_bit
135/* 139/*
136 * Find the first cleared bit in a memory region. 140 * Find the first cleared bit in a memory region.
137 */ 141 */
@@ -157,7 +161,7 @@ found:
157 return result + ffz(tmp); 161 return result + ffz(tmp);
158} 162}
159EXPORT_SYMBOL(find_first_zero_bit); 163EXPORT_SYMBOL(find_first_zero_bit);
160#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */ 164#endif
161 165
162#ifdef __BIG_ENDIAN 166#ifdef __BIG_ENDIAN
163 167
@@ -185,15 +189,17 @@ static inline unsigned long ext2_swab(const unsigned long y)
185#endif 189#endif
186} 190}
187 191
188unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, unsigned 192#ifndef find_next_zero_bit_le
193unsigned long find_next_zero_bit_le(const void *addr, unsigned
189 long size, unsigned long offset) 194 long size, unsigned long offset)
190{ 195{
191 const unsigned long *p = addr + BITOP_WORD(offset); 196 const unsigned long *p = addr;
192 unsigned long result = offset & ~(BITS_PER_LONG - 1); 197 unsigned long result = offset & ~(BITS_PER_LONG - 1);
193 unsigned long tmp; 198 unsigned long tmp;
194 199
195 if (offset >= size) 200 if (offset >= size)
196 return size; 201 return size;
202 p += BITOP_WORD(offset);
197 size -= result; 203 size -= result;
198 offset &= (BITS_PER_LONG - 1UL); 204 offset &= (BITS_PER_LONG - 1UL);
199 if (offset) { 205 if (offset) {
@@ -226,18 +232,20 @@ found_middle:
226found_middle_swap: 232found_middle_swap:
227 return result + ffz(ext2_swab(tmp)); 233 return result + ffz(ext2_swab(tmp));
228} 234}
235EXPORT_SYMBOL(find_next_zero_bit_le);
236#endif
229 237
230EXPORT_SYMBOL(generic_find_next_zero_le_bit); 238#ifndef find_next_bit_le
231 239unsigned long find_next_bit_le(const void *addr, unsigned
232unsigned long generic_find_next_le_bit(const unsigned long *addr, unsigned
233 long size, unsigned long offset) 240 long size, unsigned long offset)
234{ 241{
235 const unsigned long *p = addr + BITOP_WORD(offset); 242 const unsigned long *p = addr;
236 unsigned long result = offset & ~(BITS_PER_LONG - 1); 243 unsigned long result = offset & ~(BITS_PER_LONG - 1);
237 unsigned long tmp; 244 unsigned long tmp;
238 245
239 if (offset >= size) 246 if (offset >= size)
240 return size; 247 return size;
248 p += BITOP_WORD(offset);
241 size -= result; 249 size -= result;
242 offset &= (BITS_PER_LONG - 1UL); 250 offset &= (BITS_PER_LONG - 1UL);
243 if (offset) { 251 if (offset) {
@@ -271,5 +279,7 @@ found_middle:
271found_middle_swap: 279found_middle_swap:
272 return result + __ffs(ext2_swab(tmp)); 280 return result + __ffs(ext2_swab(tmp));
273} 281}
274EXPORT_SYMBOL(generic_find_next_le_bit); 282EXPORT_SYMBOL(find_next_bit_le);
283#endif
284
275#endif /* __BIG_ENDIAN */ 285#endif /* __BIG_ENDIAN */