aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Herring <rob.herring@calxeda.com>2011-06-28 10:39:40 -0500
committerJohn Rigby <john.rigby@linaro.org>2011-06-30 12:23:33 +0100
commit5c4b44bc48bd184c0fe0cd10fea5883f172b537f (patch)
treed311a247778cbb232d8359b166b0160d389ef143
parent5d0f72e52e83f99cfab203de3e6d62885a35d6e5 (diff)
downloadu-boot-linaro-stable-5c4b44bc48bd184c0fe0cd10fea5883f172b537f.tar.gz
arm: add __ilog2 function
Add __ilog2 function for ARM. Needed for ahci.c Signed-off-by: Rob Herring <rob.herring@calxeda.com> Cc: Albert ARIBAUD <albert.aribaud@free.fr>
-rw-r--r--arch/arm/include/asm/bitops.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h
index 270f163ee..04201822e 100644
--- a/arch/arm/include/asm/bitops.h
+++ b/arch/arm/include/asm/bitops.h
@@ -106,6 +106,15 @@ static inline int test_bit(int nr, const void * addr)
return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7));
}
+extern __inline__ int __ilog2(unsigned int x)
+{
+ int ret;
+
+ asm("clz\t%0, %1" : "=r" (ret) : "r" (x));
+ ret = 31 - ret;
+ return ret;
+}
+
/*
* ffz = Find First Zero in word. Undefined if no zero exists,
* so code should check against ~0UL first..