From 5ece5c5192d065c229da01e7b347c1d3877b59fa Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 3 Jan 2009 16:21:08 +1030 Subject: xtensa: define __fls Like fls, but can't be handed 0 and returns the bit number. Signed-off-by: Rusty Russell --- include/asm-xtensa/bitops.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/asm-xtensa') diff --git a/include/asm-xtensa/bitops.h b/include/asm-xtensa/bitops.h index 23261e8f2e5a..6c3930397bd3 100644 --- a/include/asm-xtensa/bitops.h +++ b/include/asm-xtensa/bitops.h @@ -82,6 +82,16 @@ static inline int fls (unsigned int x) return 32 - __cntlz(x); } +/** + * __fls - find last (most-significant) set bit in a long word + * @word: the word to search + * + * Undefined if no set bit exists, so code should check against 0 first. + */ +static inline unsigned long __fls(unsigned long word) +{ + return 31 - __cntlz(word); +} #else /* Use the generic implementation if we don't have the nsa/nsau instructions. */ @@ -90,6 +100,7 @@ static inline int fls (unsigned int x) # include # include # include +# include #endif -- cgit v1.2.3-59-g8ed1b