diff options
author | Jon Hunter <jon-hunter@ti.com> | 2013-04-04 16:16:14 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-04-10 17:41:16 -0400 |
commit | 3513cdeccc647d41c4a9ff923af17deaaac04a66 (patch) | |
tree | de59b9d16ef472bb6a1d12fae6c8c67489172667 /drivers/gpio | |
parent | 60b18b9aa4daa616a8b360feb35d1bfe4d606019 (diff) |
gpio/omap: optimise interrupt service routine
The OMAP GPIO interrupt service routine is checking each bit in the
GPIO interrupt status register to see which bits are set. It is not
efficient to check every bit especially if only a few bits are set.
Therefore, instead of checking every bit use the __ffs() function,
which returns the location of the first set bit, to find all the set
bits.
This optimisation was suggested-by and developed in collaboration
with Felipe Balbi.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Reviewed-by: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-omap.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 405ce6fd2e5c..f46b600e5e56 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c | |||
@@ -689,7 +689,7 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc) | |||
689 | { | 689 | { |
690 | void __iomem *isr_reg = NULL; | 690 | void __iomem *isr_reg = NULL; |
691 | u32 isr; | 691 | u32 isr; |
692 | unsigned int i; | 692 | unsigned int bit; |
693 | struct gpio_bank *bank; | 693 | struct gpio_bank *bank; |
694 | int unmasked = 0; | 694 | int unmasked = 0; |
695 | struct irq_chip *chip = irq_desc_get_chip(desc); | 695 | struct irq_chip *chip = irq_desc_get_chip(desc); |
@@ -730,9 +730,9 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc) | |||
730 | if (!isr) | 730 | if (!isr) |
731 | break; | 731 | break; |
732 | 732 | ||
733 | for (i = 0; isr != 0; isr >>= 1, i++) { | 733 | while (isr) { |
734 | if (!(isr & 1)) | 734 | bit = __ffs(isr); |
735 | continue; | 735 | isr &= ~(1 << bit); |
736 | 736 | ||
737 | /* | 737 | /* |
738 | * Some chips can't respond to both rising and falling | 738 | * Some chips can't respond to both rising and falling |
@@ -741,10 +741,10 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc) | |||
741 | * to respond to the IRQ for the opposite direction. | 741 | * to respond to the IRQ for the opposite direction. |
742 | * This will be indicated in the bank toggle_mask. | 742 | * This will be indicated in the bank toggle_mask. |
743 | */ | 743 | */ |
744 | if (bank->toggle_mask & (1 << i)) | 744 | if (bank->toggle_mask & (1 << bit)) |
745 | _toggle_gpio_edge_triggering(bank, i); | 745 | _toggle_gpio_edge_triggering(bank, bit); |
746 | 746 | ||
747 | generic_handle_irq(irq_find_mapping(bank->domain, i)); | 747 | generic_handle_irq(irq_find_mapping(bank->domain, bit)); |
748 | } | 748 | } |
749 | } | 749 | } |
750 | /* if bank has any level sensitive GPIO pin interrupt | 750 | /* if bank has any level sensitive GPIO pin interrupt |