From b2ec837f7204576556054c20116c374eb85510cf Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Sun, 17 Jun 2018 06:32:53 +0300 Subject: [PATCH] bitops: use a gcc builtin function instead of our __ffs Our __ffs implementation is straightforward and non-optimal, __builtin_ffsl should be faster. Signed-off-by: Andrei Vagin --- include/common/asm-generic/bitops.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/include/common/asm-generic/bitops.h b/include/common/asm-generic/bitops.h index fbd25c1b6..0d861bdcc 100644 --- a/include/common/asm-generic/bitops.h +++ b/include/common/asm-generic/bitops.h @@ -57,17 +57,7 @@ static inline void clear_bit(int nr, volatile unsigned long *addr) */ static inline unsigned long __ffs(unsigned long word) { - int p = 0; - - for (; p < 8*sizeof(word); ++p) { - if (word & 1) { - break; - } - - word >>= 1; - } - - return p; + return __builtin_ffsl(word) - 1; } #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG)