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.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/find_next_bit.c b/lib/find_next_bit.c
index 24c59ded47a0..b0a8767282bf 100644
--- a/lib/find_next_bit.c
+++ b/lib/find_next_bit.c
@@ -160,6 +160,7 @@ EXPORT_SYMBOL(find_first_zero_bit);
160#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */ 160#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
161 161
162#ifdef __BIG_ENDIAN 162#ifdef __BIG_ENDIAN
163#ifdef CONFIG_GENERIC_FIND_BIT_LE
163 164
164/* include/linux/byteorder does not support "unsigned long" type */ 165/* include/linux/byteorder does not support "unsigned long" type */
165static inline unsigned long ext2_swabp(const unsigned long * x) 166static inline unsigned long ext2_swabp(const unsigned long * x)
@@ -185,15 +186,16 @@ static inline unsigned long ext2_swab(const unsigned long y)
185#endif 186#endif
186} 187}
187 188
188unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, unsigned 189unsigned long find_next_zero_bit_le(const void *addr, unsigned
189 long size, unsigned long offset) 190 long size, unsigned long offset)
190{ 191{
191 const unsigned long *p = addr + BITOP_WORD(offset); 192 const unsigned long *p = addr;
192 unsigned long result = offset & ~(BITS_PER_LONG - 1); 193 unsigned long result = offset & ~(BITS_PER_LONG - 1);
193 unsigned long tmp; 194 unsigned long tmp;
194 195
195 if (offset >= size) 196 if (offset >= size)
196 return size; 197 return size;
198 p += BITOP_WORD(offset);
197 size -= result; 199 size -= result;
198 offset &= (BITS_PER_LONG - 1UL); 200 offset &= (BITS_PER_LONG - 1UL);
199 if (offset) { 201 if (offset) {
@@ -226,18 +228,18 @@ found_middle:
226found_middle_swap: 228found_middle_swap:
227 return result + ffz(ext2_swab(tmp)); 229 return result + ffz(ext2_swab(tmp));
228} 230}
231EXPORT_SYMBOL(find_next_zero_bit_le);
229 232
230EXPORT_SYMBOL(generic_find_next_zero_le_bit); 233unsigned long find_next_bit_le(const void *addr, unsigned
231
232unsigned long generic_find_next_le_bit(const unsigned long *addr, unsigned
233 long size, unsigned long offset) 234 long size, unsigned long offset)
234{ 235{
235 const unsigned long *p = addr + BITOP_WORD(offset); 236 const unsigned long *p = addr;
236 unsigned long result = offset & ~(BITS_PER_LONG - 1); 237 unsigned long result = offset & ~(BITS_PER_LONG - 1);
237 unsigned long tmp; 238 unsigned long tmp;
238 239
239 if (offset >= size) 240 if (offset >= size)
240 return size; 241 return size;
242 p += BITOP_WORD(offset);
241 size -= result; 243 size -= result;
242 offset &= (BITS_PER_LONG - 1UL); 244 offset &= (BITS_PER_LONG - 1UL);
243 if (offset) { 245 if (offset) {
@@ -271,5 +273,7 @@ found_middle:
271found_middle_swap: 273found_middle_swap:
272 return result + __ffs(ext2_swab(tmp)); 274 return result + __ffs(ext2_swab(tmp));
273} 275}
274EXPORT_SYMBOL(generic_find_next_le_bit); 276EXPORT_SYMBOL(find_next_bit_le);
277
278#endif /* CONFIG_GENERIC_FIND_BIT_LE */
275#endif /* __BIG_ENDIAN */ 279#endif /* __BIG_ENDIAN */