From a6260ef84103fa8a51a67b6a58e5e16c676e08ad Mon Sep 17 00:00:00 2001 From: Sebastian Siewior Date: Fri, 9 May 2008 16:10:37 +0200 Subject: m68knommu: add ffs and __ffs plattform which support ISA A+ or ISA C the ff1 and bitrev opcode appears in ISA C and ISA A+ what isn't supported by all plattforms. The assembly optimization is automaticly enabled if the compiler understand the required cpu keyword. My m5235 seems to boot and run fine so far. Signed-off-by: Sebastian Siewior Signed-off-by: Greg Ungerer --- include/asm-m68knommu/bitops.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'include/asm-m68knommu') diff --git a/include/asm-m68knommu/bitops.h b/include/asm-m68knommu/bitops.h index c142fbf2f37..6f3685eab44 100644 --- a/include/asm-m68knommu/bitops.h +++ b/include/asm-m68knommu/bitops.h @@ -14,8 +14,38 @@ #error only can be included directly #endif +#if defined (__mcfisaaplus__) || defined (__mcfisac__) +static inline int ffs(unsigned int val) +{ + if (!val) + return 0; + + asm volatile( + "bitrev %0\n\t" + "ff1 %0\n\t" + : "=d" (val) + : "0" (val) + ); + val++; + return val; +} + +static inline int __ffs(unsigned int val) +{ + asm volatile( + "bitrev %0\n\t" + "ff1 %0\n\t" + : "=d" (val) + : "0" (val) + ); + return val; +} + +#else #include #include +#endif + #include #include -- cgit v1.2.3