diff options
-rw-r--r-- | arch/m68k/include/asm/bitops_no.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/arch/m68k/include/asm/bitops_no.h b/arch/m68k/include/asm/bitops_no.h index 6b0e2d349f0e..b816299816ad 100644 --- a/arch/m68k/include/asm/bitops_no.h +++ b/arch/m68k/include/asm/bitops_no.h | |||
@@ -320,6 +320,50 @@ found_middle: | |||
320 | return result + ffz(__swab32(tmp)); | 320 | return result + ffz(__swab32(tmp)); |
321 | } | 321 | } |
322 | 322 | ||
323 | static inline unsigned long find_next_bit_le(const void *addr, unsigned | ||
324 | long size, unsigned long offset) | ||
325 | { | ||
326 | const unsigned long *p = addr; | ||
327 | unsigned long result = offset & ~(BITS_PER_LONG - 1); | ||
328 | unsigned long tmp; | ||
329 | |||
330 | if (offset >= size) | ||
331 | return size; | ||
332 | p += offset / BITS_PER_LONG; | ||
333 | size -= result; | ||
334 | offset &= (BITS_PER_LONG - 1UL); | ||
335 | if (offset) { | ||
336 | tmp = __swab32(*(p++)); | ||
337 | tmp &= (~0UL << offset); | ||
338 | if (size < BITS_PER_LONG) | ||
339 | goto found_first; | ||
340 | if (tmp) | ||
341 | goto found_middle; | ||
342 | size -= BITS_PER_LONG; | ||
343 | result += BITS_PER_LONG; | ||
344 | } | ||
345 | |||
346 | while (size & ~(BITS_PER_LONG - 1)) { | ||
347 | tmp = *(p++); | ||
348 | if (tmp) | ||
349 | goto found_middle_swap; | ||
350 | result += BITS_PER_LONG; | ||
351 | size -= BITS_PER_LONG; | ||
352 | } | ||
353 | if (!size) | ||
354 | return result; | ||
355 | tmp = __swab32(*p); | ||
356 | found_first: | ||
357 | tmp &= (~0UL >> (BITS_PER_LONG - size)); | ||
358 | if (tmp == 0UL) /* Are any bits set? */ | ||
359 | return result + size; /* Nope. */ | ||
360 | found_middle: | ||
361 | return result + __ffs(tmp); | ||
362 | |||
363 | found_middle_swap: | ||
364 | return result + __ffs(__swab32(tmp)); | ||
365 | } | ||
366 | |||
323 | #endif /* __KERNEL__ */ | 367 | #endif /* __KERNEL__ */ |
324 | 368 | ||
325 | #include <asm-generic/bitops/fls.h> | 369 | #include <asm-generic/bitops/fls.h> |