From 046ddd0244e3148d362e2c7c2afa14c74fe06c6f Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Thu, 26 May 2011 16:26:05 -0700 Subject: [PATCH] --- yaml --- r: 252072 b: refs/heads/master c: e0819410dba141338ebf6ab1057c1863be6247ab h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/arch/m68k/include/asm/bitops_no.h | 44 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index fa20c5ab6681..70b73e266233 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 275ac74629c4d8ec430d7edecb16d936f46a47c5 +refs/heads/master: e0819410dba141338ebf6ab1057c1863be6247ab diff --git a/trunk/arch/m68k/include/asm/bitops_no.h b/trunk/arch/m68k/include/asm/bitops_no.h index 6b0e2d349f0e..b816299816ad 100644 --- a/trunk/arch/m68k/include/asm/bitops_no.h +++ b/trunk/arch/m68k/include/asm/bitops_no.h @@ -320,6 +320,50 @@ static inline unsigned long find_next_zero_bit_le(void *addr, unsigned long size return result + ffz(__swab32(tmp)); } +static inline unsigned long find_next_bit_le(const void *addr, unsigned + long size, unsigned long offset) +{ + const unsigned long *p = addr; + unsigned long result = offset & ~(BITS_PER_LONG - 1); + unsigned long tmp; + + if (offset >= size) + return size; + p += offset / BITS_PER_LONG; + size -= result; + offset &= (BITS_PER_LONG - 1UL); + if (offset) { + tmp = __swab32(*(p++)); + tmp &= (~0UL << offset); + if (size < BITS_PER_LONG) + goto found_first; + if (tmp) + goto found_middle; + size -= BITS_PER_LONG; + result += BITS_PER_LONG; + } + + while (size & ~(BITS_PER_LONG - 1)) { + tmp = *(p++); + if (tmp) + goto found_middle_swap; + result += BITS_PER_LONG; + size -= BITS_PER_LONG; + } + if (!size) + return result; + tmp = __swab32(*p); +found_first: + tmp &= (~0UL >> (BITS_PER_LONG - size)); + if (tmp == 0UL) /* Are any bits set? */ + return result + size; /* Nope. */ +found_middle: + return result + __ffs(tmp); + +found_middle_swap: + return result + __ffs(__swab32(tmp)); +} + #endif /* __KERNEL__ */ #include