From patchwork Tue Mar 17 15:09:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 451011 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 72C5E1401AB for ; Wed, 18 Mar 2015 02:13:28 +1100 (AEDT) Received: from localhost ([::1]:55289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXtBO-0007N5-7R for incoming@patchwork.ozlabs.org; Tue, 17 Mar 2015 11:13:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXt8G-0001Th-Q1 for qemu-devel@nongnu.org; Tue, 17 Mar 2015 11:10:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXt8B-0003mS-VN for qemu-devel@nongnu.org; Tue, 17 Mar 2015 11:10:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXt8B-0003lp-P7 for qemu-devel@nongnu.org; Tue, 17 Mar 2015 11:10:07 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2HFA5vO009526 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 17 Mar 2015 11:10:05 -0400 Received: from localhost (ovpn-112-52.ams2.redhat.com [10.36.112.52]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2HFA4wr003275; Tue, 17 Mar 2015 11:10:05 -0400 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Tue, 17 Mar 2015 15:09:45 +0000 Message-Id: <1426604987-11363-8-git-send-email-stefanha@redhat.com> In-Reply-To: <1426604987-11363-1-git-send-email-stefanha@redhat.com> References: <1426604987-11363-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Markus Armbruster , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH v2 7/9] omap_intc: convert ffs(3) to ctz32() in omap_inth_sir_update() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Signed-off-by: Stefan Hajnoczi --- hw/intc/omap_intc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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;