From patchwork Mon Dec 9 16:21:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 3311711 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0C0B99F37C for ; Mon, 9 Dec 2013 16:22:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EB8C2202F8 for ; Mon, 9 Dec 2013 16:22:50 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 98116202E9 for ; Mon, 9 Dec 2013 16:22:49 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vq3bZ-0008D0-G8; Mon, 09 Dec 2013 16:22:45 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vq3bW-0001bO-R3; Mon, 09 Dec 2013 16:22:42 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vq3bQ-0001YQ-NI for linux-arm-kernel@lists.infradead.org; Mon, 09 Dec 2013 16:22:37 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id rB9GM6VB009828; Mon, 9 Dec 2013 10:22:06 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id rB9GM6e3027771; Mon, 9 Dec 2013 10:22:06 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Mon, 9 Dec 2013 10:22:05 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id rB9GM6sf018411; Mon, 9 Dec 2013 10:22:06 -0600 From: Felipe Balbi To: Subject: [PATCH v3 05/15] mfd: menelaus: Use for_each_set_bit() Date: Mon, 9 Dec 2013 10:21:15 -0600 Message-ID: <1386606085-26838-5-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.8.4.GIT In-Reply-To: <1386606085-26838-1-git-send-email-balbi@ti.com> References: <20131209161422.GC24047@saruman.home> <1386606085-26838-1-git-send-email-balbi@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131209_112236_875257_5BB56032 X-CRM114-Status: UNSURE ( 8.77 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -6.9 (------) Cc: Aaro Koskinen , Tony Lindgren , Linux Kernel Mailing List , Felipe Balbi , Linux OMAP Mailing List , Linux ARM Kernel Mailing List X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP That macro just helps removing some extra line of code and hides ffs() calls. While at that, also fix a variable shadowing bug where 'int irq' was being redeclared inside inner loop while it was also argument to interrupt handler. Tested-by: Aaro Koskinen Signed-off-by: Felipe Balbi --- drivers/mfd/menelaus.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c index 11dc4d3..9ccbb79 100644 --- a/drivers/mfd/menelaus.c +++ b/drivers/mfd/menelaus.c @@ -795,24 +795,22 @@ static irqreturn_t menelaus_irq(int irq, void *_menelaus) { struct menelaus_chip *menelaus = _menelaus; void (*handler)(struct menelaus_chip *menelaus); - unsigned isr; + unsigned long isr; + unsigned long i; isr = (menelaus_read_reg(MENELAUS_INT_STATUS2) & ~menelaus->mask2) << 8; isr |= menelaus_read_reg(MENELAUS_INT_STATUS1) & ~menelaus->mask1; - while (isr) { - int irq = fls(isr) - 1; - isr &= ~(1 << irq); - + for_each_set_bit(i, &isr, 16) { mutex_lock(&menelaus->lock); - menelaus_disable_irq(irq); - menelaus_ack_irq(irq); - handler = menelaus->handlers[irq]; + menelaus_disable_irq(i); + menelaus_ack_irq(i); + handler = menelaus->handlers[i]; if (handler) handler(menelaus); - menelaus_enable_irq(irq); + menelaus_enable_irq(i); mutex_unlock(&menelaus->lock); }