[ARM] 5339/1: fix __fls() on ARM

Commit 0c65f459ce6c intended to fix truncation issues with fls() on
ARMv5+ by renaming it to __fls() and wrapping it into a C function.
However that didn't take into account the fact that __fls() already
already had different semantics in the kernel.

Let's move the __fls() code into fls() function directly, and redefine
__fls() with the appropriate semantics. While at it, bring a generic
__fls() definition for pre ARMv5 too.

Signed-off-by: Nicolas Pitre <nico@marvell.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Nicolas Pitre and committed by Russell King 94fc7336 82676d76

+10 -6
+10 -6
arch/arm/include/asm/bitops.h
··· 237 #if __LINUX_ARM_ARCH__ < 5 238 239 #include <asm-generic/bitops/ffz.h> 240 #include <asm-generic/bitops/__ffs.h> 241 #include <asm-generic/bitops/fls.h> 242 #include <asm-generic/bitops/ffs.h> ··· 278 * the clz instruction for much better code efficiency. 279 */ 280 281 - #define __fls(x) \ 282 - ( __builtin_constant_p(x) ? constant_fls(x) : \ 283 - ({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 32-__r; }) ) 284 - 285 - /* Implement fls() in C so that 64-bit args are suitably truncated */ 286 static inline int fls(int x) 287 { 288 - return __fls(x); 289 } 290 291 #define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); }) 292 #define __ffs(x) (ffs(x) - 1) 293 #define ffz(x) __ffs( ~(x) )
··· 237 #if __LINUX_ARM_ARCH__ < 5 238 239 #include <asm-generic/bitops/ffz.h> 240 + #include <asm-generic/bitops/__fls.h> 241 #include <asm-generic/bitops/__ffs.h> 242 #include <asm-generic/bitops/fls.h> 243 #include <asm-generic/bitops/ffs.h> ··· 277 * the clz instruction for much better code efficiency. 278 */ 279 280 static inline int fls(int x) 281 { 282 + int ret; 283 + 284 + if (__builtin_constant_p(x)) 285 + return constant_fls(x); 286 + 287 + asm("clz\t%0, %1" : "=r" (ret) : "r" (x) : "cc"); 288 + ret = 32 - ret; 289 + return ret; 290 } 291 292 + #define __fls(x) (fls(x) - 1) 293 #define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); }) 294 #define __ffs(x) (ffs(x) - 1) 295 #define ffz(x) __ffs( ~(x) )