diff options
author | Linus Torvalds <torvalds@evo.osdl.org> | 2005-07-29 11:01:22 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-07-29 11:01:22 -0400 |
commit | d6d2a2ab05da6e44bd127fe375078bb7c36a0ad0 (patch) | |
tree | 7b4f2893d8c09fba67c83458efeea9396977bc70 /include/asm-i386 | |
parent | 33ac02aa4cef417871e128ab4a6565e751e5f3b2 (diff) |
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>
Diffstat (limited to 'include/asm-i386')
-rw-r--r-- | include/asm-i386/bitops.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h index 1caee1039363..ddf1739dc7fd 100644 --- a/include/asm-i386/bitops.h +++ b/include/asm-i386/bitops.h | |||
@@ -335,14 +335,13 @@ static inline unsigned long __ffs(unsigned long word) | |||
335 | static inline int find_first_bit(const unsigned long *addr, unsigned size) | 335 | static inline int find_first_bit(const unsigned long *addr, unsigned size) |
336 | { | 336 | { |
337 | int x = 0; | 337 | int x = 0; |
338 | do { | 338 | |
339 | if (*addr) | 339 | while (x < size) { |
340 | return __ffs(*addr) + x; | 340 | unsigned long val = *addr++; |
341 | addr++; | 341 | if (val) |
342 | if (x >= size) | 342 | return __ffs(val) + x; |
343 | break; | ||
344 | x += (sizeof(*addr)<<3); | 343 | x += (sizeof(*addr)<<3); |
345 | } while (1); | 344 | } |
346 | return x; | 345 | return x; |
347 | } | 346 | } |
348 | 347 | ||