aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2010-02-08 15:02:30 -0500
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>2010-02-24 04:06:57 -0500
commit3621f188b945a9f9bc1387115834041b7a4619e0 (patch)
tree6ad70878e56e3be6db728e9a0341ddfe22c5d477
parent3244c3e7797d235250cd01d4a1d3f60b3b2f6261 (diff)
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: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
-rw-r--r--arch/arm/plat-mxc/gpio.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/arch/arm/plat-mxc/gpio.c b/arch/arm/plat-mxc/gpio.c
index bee100b7e937..0b11554dadac 100644
--- a/arch/arm/plat-mxc/gpio.c
+++ b/arch/arm/plat-mxc/gpio.c
@@ -154,24 +154,22 @@ static void mxc_flip_edge(struct mxc_gpio_port *port, u32 gpio)
154 __raw_writel(val | (edge << (bit << 1)), reg); 154 __raw_writel(val | (edge << (bit << 1)), reg);
155} 155}
156 156
157/* handle n interrupts in one status register */ 157/* handle 32 interrupts in one status register */
158static void mxc_gpio_irq_handler(struct mxc_gpio_port *port, u32 irq_stat) 158static void mxc_gpio_irq_handler(struct mxc_gpio_port *port, u32 irq_stat)
159{ 159{
160 u32 gpio_irq_no; 160 u32 gpio_irq_no_base = port->virtual_irq_start;
161 161
162 gpio_irq_no = port->virtual_irq_start; 162 while (irq_stat != 0) {
163 for (; irq_stat != 0; irq_stat >>= 1, gpio_irq_no++) { 163 int irqoffset = fls(irq_stat) - 1;
164 u32 gpio = irq_to_gpio(gpio_irq_no);
165 164
166 if ((irq_stat & 1) == 0) 165 BUG_ON(!(irq_desc[gpio_irq_no_base + irqoffset].handle_irq));
167 continue;
168 166
169 BUG_ON(!(irq_desc[gpio_irq_no].handle_irq)); 167 if (port->both_edges & (1 << irqoffset))
168 mxc_flip_edge(port, irqoffset);
170 169
171 if (port->both_edges & (1 << (gpio & 31))) 170 generic_handle_irq(gpio_irq_no_base + irqoffset);
172 mxc_flip_edge(port, gpio);
173 171
174 generic_handle_irq(gpio_irq_no); 172 irq_stat &= ~(1 << irqoffset);
175 } 173 }
176} 174}
177 175