diff mbox

[v2,7/9] omap_intc: convert ffs(3) to ctz32() in omap_inth_sir_update()

Message ID 1426604987-11363-8-git-send-email-stefanha@redhat.com
State New
Headers show

Commit Message

Stefan Hajnoczi March 17, 2015, 3:09 p.m. UTC
The loop previously terminated on ffs(0) == 0, now it terminates on
ctz32(0) + 1 == 33.

Other than this change, ffs() is simply replaced with ctz32() + 1.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/intc/omap_intc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/hw/intc/omap_intc.c b/hw/intc/omap_intc.c
index ad3931c..0cf2d2d 100644
--- a/hw/intc/omap_intc.c
+++ b/hw/intc/omap_intc.c
@@ -72,14 +72,15 @@  static void omap_inth_sir_update(struct omap_intr_handler_s *s, int is_fiq)
     for (j = 0; j < s->nbanks; ++j) {
         level = s->bank[j].irqs & ~s->bank[j].mask &
                 (is_fiq ? s->bank[j].fiq : ~s->bank[j].fiq);
-        for (f = ffs(level), i = f - 1, level >>= f - 1; f; i += f,
-                        level >>= f) {
+        for (f = ctz32(level) + 1, i = f - 1, level >>= f - 1;
+             f != 33;
+             i += f, level >>= f) {
             p = s->bank[j].priority[i];
             if (p <= p_intr) {
                 p_intr = p;
                 sir_intr = 32 * j + i;
             }
-            f = ffs(level >> 1);
+            f = ctz32(level >> 1) + 1;
         }
     }
     s->sir_intr[is_fiq] = sir_intr;