diff options
-rw-r--r-- | include/asm-frv/bitops.h | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/include/asm-frv/bitops.h b/include/asm-frv/bitops.h index 591eecc1f8cd..1f70d47148bd 100644 --- a/include/asm-frv/bitops.h +++ b/include/asm-frv/bitops.h | |||
@@ -157,8 +157,6 @@ static inline int __test_bit(int nr, const volatile void * addr) | |||
157 | __constant_test_bit((nr),(addr)) : \ | 157 | __constant_test_bit((nr),(addr)) : \ |
158 | __test_bit((nr),(addr))) | 158 | __test_bit((nr),(addr))) |
159 | 159 | ||
160 | #include <asm-generic/bitops/ffs.h> | ||
161 | #include <asm-generic/bitops/__ffs.h> | ||
162 | #include <asm-generic/bitops/find.h> | 160 | #include <asm-generic/bitops/find.h> |
163 | 161 | ||
164 | /** | 162 | /** |
@@ -227,6 +225,37 @@ int fls64(u64 n) | |||
227 | 225 | ||
228 | } | 226 | } |
229 | 227 | ||
228 | /** | ||
229 | * ffs - find first bit set | ||
230 | * @x: the word to search | ||
231 | * | ||
232 | * - return 32..1 to indicate bit 31..0 most least significant bit set | ||
233 | * - return 0 to indicate no bits set | ||
234 | */ | ||
235 | static inline __attribute__((const)) | ||
236 | int ffs(int x) | ||
237 | { | ||
238 | /* Note: (x & -x) gives us a mask that is the least significant | ||
239 | * (rightmost) 1-bit of the value in x. | ||
240 | */ | ||
241 | return fls(x & -x); | ||
242 | } | ||
243 | |||
244 | /** | ||
245 | * __ffs - find first bit set | ||
246 | * @x: the word to search | ||
247 | * | ||
248 | * - return 31..0 to indicate bit 31..0 most least significant bit set | ||
249 | * - if no bits are set in x, the result is undefined | ||
250 | */ | ||
251 | static inline __attribute__((const)) | ||
252 | int __ffs(unsigned long x) | ||
253 | { | ||
254 | int bit; | ||
255 | asm("scan %1,gr0,%0" : "=r"(bit) : "r"(x & -x)); | ||
256 | return 31 - bit; | ||
257 | } | ||
258 | |||
230 | #include <asm-generic/bitops/sched.h> | 259 | #include <asm-generic/bitops/sched.h> |
231 | #include <asm-generic/bitops/hweight.h> | 260 | #include <asm-generic/bitops/hweight.h> |
232 | 261 | ||