From 0999769e6cad9b0e5abb7c513c0c3f16821f0884 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 3 Jan 2009 15:37:14 +1030 Subject: cris: define __fls Like fls, but can't be handed 0 and returns the bit number. Signed-off-by: Rusty Russell diff --git a/arch/cris/include/asm/bitops.h b/arch/cris/include/asm/bitops.h index c0e62f8..9e69cfb 100644 --- a/arch/cris/include/asm/bitops.h +++ b/arch/cris/include/asm/bitops.h @@ -148,6 +148,7 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr) #define ffs kernel_ffs #include +#include #include #include #include -- cgit v0.10.2 From ee38e5140bafbf40e1bd25ab917ac8db54a27799 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 3 Jan 2009 16:14:05 +1030 Subject: frv: define __fls Like fls, but can't be handed 0 and returns the bit number. Signed-off-by: Rusty Russell diff --git a/include/asm-frv/bitops.h b/include/asm-frv/bitops.h index 39456ba..287f6f6 100644 --- a/include/asm-frv/bitops.h +++ b/include/asm-frv/bitops.h @@ -339,6 +339,19 @@ int __ffs(unsigned long x) return 31 - bit; } +/** + * __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) +{ + unsigned long bit; + asm("scan %1,gr0,%0" : "=r"(bit) : "r"(word)); + return bit; +} + /* * special slimline version of fls() for calculating ilog2_u32() * - note: no protection against n == 0 -- cgit v0.10.2 From 9ddabc2a29163e4b243d10c5e06fc5584073d7ad Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 3 Jan 2009 16:16:04 +1030 Subject: h8300: define __fls Like fls, but can't be handed 0 and returns the bit number. Signed-off-by: Rusty Russell diff --git a/arch/h8300/include/asm/bitops.h b/arch/h8300/include/asm/bitops.h index cb18e3b..cb9ddf5 100644 --- a/arch/h8300/include/asm/bitops.h +++ b/arch/h8300/include/asm/bitops.h @@ -207,6 +207,7 @@ static __inline__ unsigned long __ffs(unsigned long word) #endif /* __KERNEL__ */ #include +#include #include #endif /* _H8300_BITOPS_H */ -- cgit v0.10.2 From 16a206260ee70f181de6a3672678545859589ef2 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 3 Jan 2009 16:16:54 +1030 Subject: m32r: define __fls Like fls, but can't be handed 0 and returns the bit number. Signed-off-by: Rusty Russell diff --git a/include/asm-m32r/bitops.h b/include/asm-m32r/bitops.h index 6dc9b81..aaddf0d 100644 --- a/include/asm-m32r/bitops.h +++ b/include/asm-m32r/bitops.h @@ -251,6 +251,7 @@ static __inline__ int test_and_change_bit(int nr, volatile void * addr) #include #include #include +#include #include #ifdef __KERNEL__ -- cgit v0.10.2 From 5c134dad43443aa9c9606eaf47c378a6b9c5c597 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 3 Jan 2009 16:19:03 +1030 Subject: mn10300: define __fls Like fls, but can't be handed 0 and returns the bit number. Signed-off-by: Rusty Russell diff --git a/include/asm-mn10300/bitops.h b/include/asm-mn10300/bitops.h index cc6d40c..0b610f4 100644 --- a/include/asm-mn10300/bitops.h +++ b/include/asm-mn10300/bitops.h @@ -196,6 +196,17 @@ int fls(int 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 __ilog2_u32(word); +} + +/** * ffs - find first bit set * @x: the word to search * -- cgit v0.10.2 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 diff --git a/include/asm-xtensa/bitops.h b/include/asm-xtensa/bitops.h index 23261e8..6c39303 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 v0.10.2