Commit 3621f188 authored by Uwe Kleine-König's avatar Uwe Kleine-König

arm/imx/gpio: use fls to find set bits in the irq status register

As in most cases only few irqs are pending using fls is more effective
than looping over all bits.
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent 3244c3e7
...@@ -154,24 +154,22 @@ static void mxc_flip_edge(struct mxc_gpio_port *port, u32 gpio) ...@@ -154,24 +154,22 @@ static void mxc_flip_edge(struct mxc_gpio_port *port, u32 gpio)
__raw_writel(val | (edge << (bit << 1)), reg); __raw_writel(val | (edge << (bit << 1)), reg);
} }
/* handle n interrupts in one status register */ /* handle 32 interrupts in one status register */
static void mxc_gpio_irq_handler(struct mxc_gpio_port *port, u32 irq_stat) static void mxc_gpio_irq_handler(struct mxc_gpio_port *port, u32 irq_stat)
{ {
u32 gpio_irq_no; u32 gpio_irq_no_base = port->virtual_irq_start;
gpio_irq_no = port->virtual_irq_start; while (irq_stat != 0) {
for (; irq_stat != 0; irq_stat >>= 1, gpio_irq_no++) { int irqoffset = fls(irq_stat) - 1;
u32 gpio = irq_to_gpio(gpio_irq_no);
if ((irq_stat & 1) == 0) BUG_ON(!(irq_desc[gpio_irq_no_base + irqoffset].handle_irq));
continue;
BUG_ON(!(irq_desc[gpio_irq_no].handle_irq)); if (port->both_edges & (1 << irqoffset))
mxc_flip_edge(port, irqoffset);
if (port->both_edges & (1 << (gpio & 31))) generic_handle_irq(gpio_irq_no_base + irqoffset);
mxc_flip_edge(port, gpio);
generic_handle_irq(gpio_irq_no); irq_stat &= ~(1 << irqoffset);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment