diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2009-01-03 00:44:05 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-01-03 00:44:05 -0500 |
commit | ee38e5140bafbf40e1bd25ab917ac8db54a27799 (patch) | |
tree | e05484a09e8b73692fd16663dd6b3deafc5116dc /include/asm-frv | |
parent | 0999769e6cad9b0e5abb7c513c0c3f16821f0884 (diff) |
frv: define __fls
Like fls, but can't be handed 0 and returns the bit number.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'include/asm-frv')
-rw-r--r-- | include/asm-frv/bitops.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/asm-frv/bitops.h b/include/asm-frv/bitops.h index 39456ba0ec17..287f6f697ce2 100644 --- a/include/asm-frv/bitops.h +++ b/include/asm-frv/bitops.h | |||
@@ -339,6 +339,19 @@ int __ffs(unsigned long x) | |||
339 | return 31 - bit; | 339 | return 31 - bit; |
340 | } | 340 | } |
341 | 341 | ||
342 | /** | ||
343 | * __fls - find last (most-significant) set bit in a long word | ||
344 | * @word: the word to search | ||
345 | * | ||
346 | * Undefined if no set bit exists, so code should check against 0 first. | ||
347 | */ | ||
348 | static inline unsigned long __fls(unsigned long word) | ||
349 | { | ||
350 | unsigned long bit; | ||
351 | asm("scan %1,gr0,%0" : "=r"(bit) : "r"(word)); | ||
352 | return bit; | ||
353 | } | ||
354 | |||
342 | /* | 355 | /* |
343 | * special slimline version of fls() for calculating ilog2_u32() | 356 | * special slimline version of fls() for calculating ilog2_u32() |
344 | * - note: no protection against n == 0 | 357 | * - note: no protection against n == 0 |