0001
0002 #ifndef _ASM_GENERIC_BITOPS___FFS_H_
0003 #define _ASM_GENERIC_BITOPS___FFS_H_
0004
0005 #include <asm/types.h>
0006
0007
0008
0009
0010
0011
0012
0013 static __always_inline unsigned long __ffs(unsigned long word)
0014 {
0015 int num = 0;
0016
0017 #if BITS_PER_LONG == 64
0018 if ((word & 0xffffffff) == 0) {
0019 num += 32;
0020 word >>= 32;
0021 }
0022 #endif
0023 if ((word & 0xffff) == 0) {
0024 num += 16;
0025 word >>= 16;
0026 }
0027 if ((word & 0xff) == 0) {
0028 num += 8;
0029 word >>= 8;
0030 }
0031 if ((word & 0xf) == 0) {
0032 num += 4;
0033 word >>= 4;
0034 }
0035 if ((word & 0x3) == 0) {
0036 num += 2;
0037 word >>= 2;
0038 }
0039 if ((word & 0x1) == 0)
0040 num += 1;
0041 return num;
0042 }
0043
0044 #endif