Patchwork [U-Boot,v2] arm: add __ilog2 function

login
register
mail settings
Submitter Rob Herring
Date July 5, 2011, 2:38 p.m.
Message ID <1309876731-15966-1-git-send-email-robherring2@gmail.com>
Download mbox | patch
Permalink /patch/103313/
State Accepted
Commit 0b9bc73711aed13246dd2cb91a3f658eeb25baf5
Delegated to: Albert ARIBAUD
Headers show

Comments

Rob Herring - July 5, 2011, 2:38 p.m.
From: Rob Herring <rob.herring@calxeda.com>

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>
---
Performance here is not critical, so I'm changing this to use the C
version. 

v2 changes:
- Change __inline__ to inline.
- Use generic_fls function instead of clz asm so it works with ARMv4.

 arch/arm/include/asm/bitops.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
Albert ARIBAUD - July 16, 2011, 11:01 a.m.
Hi Rob,

Le 05/07/2011 16:38, Rob Herring a écrit :
> From: Rob Herring<rob.herring@calxeda.com>
>
> 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>
> ---

Applied to u-boot-arm/master, thanks!

(but please do not use my old e-mail address)

Amicalement,

Patch

diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h
index 270f163..879e20e 100644
--- a/arch/arm/include/asm/bitops.h
+++ b/arch/arm/include/asm/bitops.h
@@ -106,6 +106,11 @@  static inline int test_bit(int nr, const void * addr)
     return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7));
 }
 
+static inline int __ilog2(unsigned int x)
+{
+	return generic_fls(x) - 1;
+}
+
 /*
  * ffz = Find First Zero in word. Undefined if no zero exists,
  * so code should check against ~0UL first..