x86: fix new find_first_bit()
Some edge problems with the original C rewrite. Thanks go to Cal Peake, who pinpointed the breakage to the rewrite, and tested this fixed version. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
33ac02aa4c
commit
d6d2a2ab05
1 changed files with 6 additions and 7 deletions
|
@ -335,14 +335,13 @@ static inline unsigned long __ffs(unsigned long word)
|
||||||
static inline int find_first_bit(const unsigned long *addr, unsigned size)
|
static inline int find_first_bit(const unsigned long *addr, unsigned size)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
do {
|
|
||||||
if (*addr)
|
while (x < size) {
|
||||||
return __ffs(*addr) + x;
|
unsigned long val = *addr++;
|
||||||
addr++;
|
if (val)
|
||||||
if (x >= size)
|
return __ffs(val) + x;
|
||||||
break;
|
|
||||||
x += (sizeof(*addr)<<3);
|
x += (sizeof(*addr)<<3);
|
||||||
} while (1);
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue