I don't know if there are less efficient ways to code that. Get rid of
the loop mess and use efficient code.

Signed-off-by: Thomas Gleixner <t...@linutronix.de>
---
 drivers/irqchip/spear-shirq.c |   19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

Index: linux/drivers/irqchip/spear-shirq.c
===================================================================
--- linux.orig/drivers/irqchip/spear-shirq.c
+++ linux/drivers/irqchip/spear-shirq.c
@@ -224,23 +224,20 @@ static void shirq_handler(unsigned irq,
        struct spear_shirq *shirq = irq_get_handler_data(irq);
        struct irq_data *idata = irq_desc_get_irq_data(desc);
        struct irq_chip *chip = irq_data_get_irq_chip(idata);
-       u32 i, j, val, mask;
+       u32 pend;
 
        chip->irq_ack(idata);
 
-       mask = shirq->mask;
-       while ((val = readl(shirq->base + shirq->regs.status_reg) &
-                               mask)) {
+       pend = readl(shirq->base + shirq->regs.status_reg) & shirq->mask;
+       pend >>= shirq->offset;
 
-               val >>= shirq->offset;
-               for (i = 0, j = 1; i < shirq->nr_irqs; i++, j <<= 1) {
+       while (pend) {
+               int irq = __ffs(pend);
 
-                       if (!(j & val))
-                               continue;
-
-                       generic_handle_irq(shirq->virq_base + i);
-               }
+               pend &= ~(0x1 << irq);
+               generic_handle_irq(shirq->virq_base + irq);
        }
+
        chip->irq_unmask(idata);
 }
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to