aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@evo.osdl.org>2005-07-29 11:01:22 -0400
committerLinus Torvalds <torvalds@evo.osdl.org>2005-07-29 11:01:22 -0400
commitd6d2a2ab05da6e44bd127fe375078bb7c36a0ad0 (patch)
tree7b4f2893d8c09fba67c83458efeea9396977bc70 /include
parent33ac02aa4cef417871e128ab4a6565e751e5f3b2 (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')
-rw-r--r--include/asm-i386/bitops.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h
index 1caee103936..ddf1739dc7f 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)
static inline int find_first_bit(const unsigned long *addr, unsigned size)
{
int x = 0;
- do {
- if (*addr)
- return __ffs(*addr) + x;
- addr++;
- if (x >= size)
- break;
+
+ while (x < size) {
+ unsigned long val = *addr++;
+ if (val)
+ return __ffs(val) + x;
x += (sizeof(*addr)<<3);
- } while (1);
+ }
return x;
}