[U-Boot] [PATCH 3/6] arm: add __ilog2 function

Aneesh V aneesh at ti.com
Tue Jul 5 06:42:59 CEST 2011


Hi Rob,

On Tuesday 28 June 2011 09:09 PM, Rob Herring wrote:
> From: Rob Herring<rob.herring at calxeda.com>
>
> Add __ilog2 function for ARM. Needed for ahci.c
>
> Signed-off-by: Rob Herring<rob.herring at calxeda.com>
> Cc: Albert ARIBAUD<albert.aribaud at free.fr>
> ---
>   arch/arm/include/asm/bitops.h |    9 +++++++++
>   1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h
> index 270f163..0420182 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));

I tried doing the same sometime back for the same need. I had to
abandon it because CLZ seems to be added only in ARMv5. And at least
one ARMv7 SoC uses -march=armv4 while building.

best regards,
Aneesh


More information about the U-Boot mailing list