summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2009-01-03 16:14:05 +1030
committerRusty Russell <rusty@rustcorp.com.au>2009-01-03 16:14:05 +1030
commitee38e5140bafbf40e1bd25ab917ac8db54a27799 (patch)
treee05484a09e8b73692fd16663dd6b3deafc5116dc
parent0999769e6cad9b0e5abb7c513c0c3f16821f0884 (diff)
downloadop-kernel-dev-ee38e5140bafbf40e1bd25ab917ac8db54a27799.zip
op-kernel-dev-ee38e5140bafbf40e1bd25ab917ac8db54a27799.tar.gz
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>
-rw-r--r--include/asm-frv/bitops.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/asm-frv/bitops.h b/include/asm-frv/bitops.h
index 39456ba..287f6f6 100644
--- a/include/asm-frv/bitops.h
+++ b/include/asm-frv/bitops.h
@@ -339,6 +339,19 @@ int __ffs(unsigned long x)
return 31 - bit;
}
+/**
+ * __fls - find last (most-significant) set bit in a long word
+ * @word: the word to search
+ *
+ * Undefined if no set bit exists, so code should check against 0 first.
+ */
+static inline unsigned long __fls(unsigned long word)
+{
+ unsigned long bit;
+ asm("scan %1,gr0,%0" : "=r"(bit) : "r"(word));
+ return bit;
+}
+
/*
* special slimline version of fls() for calculating ilog2_u32()
* - note: no protection against n == 0
OpenPOWER on IntegriCloud