From: Linus Torvalds Date: Fri, 29 Jul 2005 15:01:22 +0000 (-0400) Subject: x86: fix new find_first_bit() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d6d2a2ab05da6e44bd127fe375078bb7c36a0ad0;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 --- 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) 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; }