linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] gpio: zynq: Reduce level of indention in zynq_gpio_irqhandler()
@ 2014-08-18  9:54 Lars-Peter Clausen
  2014-08-18  9:54 ` [PATCH v2 2/2] gpio: zynq: Take bank offset into account when reporting a IRQ Lars-Peter Clausen
  2014-08-29  6:33 ` [PATCH 1/2] gpio: zynq: Reduce level of indention in zynq_gpio_irqhandler() Linus Walleij
  0 siblings, 2 replies; 12+ messages in thread
From: Lars-Peter Clausen @ 2014-08-18  9:54 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot
  Cc: Michal Simek, Harini Katakam, Sören Brinkmann, linux-gpio,
	Lars-Peter Clausen

zynq_gpio_irqhandler() uses up to 7 tabs of indention in some parts. Refactor
things to use a helper function for the inner loop to reduce the indention to a
sane level.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/gpio/gpio-zynq.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
index 31ad5df..f440317 100644
--- a/drivers/gpio/gpio-zynq.c
+++ b/drivers/gpio/gpio-zynq.c
@@ -457,6 +457,24 @@ static struct irq_chip zynq_gpio_edge_irqchip = {
 	.irq_set_wake	= zynq_gpio_set_wake,
 };
 
+static void zynq_gpio_handle_bank_irq(struct zynq_gpio *gpio,
+				      unsigned int bank_num,
+				      unsigned long pending)
+{
+	struct irq_domain *irqdomain = gpio->chip.irqdomain;
+	int offset;
+
+	if (!pending)
+		return;
+
+	for_each_set_bit(offset, &pending, 32) {
+		unsigned int gpio_irq;
+
+		gpio_irq = irq_find_mapping(irqdomain, offset);
+		generic_handle_irq(gpio_irq);
+	}
+}
+
 /**
  * zynq_gpio_irqhandler - IRQ handler for the gpio banks of a gpio device
  * @irq:	irq number of the gpio bank where interrupt has occurred
@@ -482,18 +500,7 @@ static void zynq_gpio_irqhandler(unsigned int irq, struct irq_desc *desc)
 					ZYNQ_GPIO_INTSTS_OFFSET(bank_num));
 		int_enb = readl_relaxed(gpio->base_addr +
 					ZYNQ_GPIO_INTMASK_OFFSET(bank_num));
-		int_sts &= ~int_enb;
-		if (int_sts) {
-			int offset;
-			unsigned long pending = int_sts;
-
-			for_each_set_bit(offset, &pending, 32) {
-				unsigned int gpio_irq =
-					irq_find_mapping(gpio->chip.irqdomain,
-							offset);
-				generic_handle_irq(gpio_irq);
-			}
-		}
+		zynq_gpio_handle_bank_irq(gpio, bank_num, int_sts & ~int_enb);
 	}
 
 	chained_irq_exit(irqchip, desc);
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-09-03 11:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-18  9:54 [PATCH 1/2] gpio: zynq: Reduce level of indention in zynq_gpio_irqhandler() Lars-Peter Clausen
2014-08-18  9:54 ` [PATCH v2 2/2] gpio: zynq: Take bank offset into account when reporting a IRQ Lars-Peter Clausen
2014-08-18 16:28   ` Alexandre Courbot
2014-08-18 18:54     ` Sören Brinkmann
2014-08-18 19:04       ` Harini Katakam
2014-08-21 12:40   ` Linus Walleij
2014-08-21 13:30     ` Lars-Peter Clausen
2014-08-29  7:20       ` Linus Walleij
2014-08-29  7:34         ` Lars-Peter Clausen
2014-08-29  9:33           ` Michal Simek
2014-09-03 11:57             ` Linus Walleij
2014-08-29  6:33 ` [PATCH 1/2] gpio: zynq: Reduce level of indention in zynq_gpio_irqhandler() Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).