linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Courbot <gnurou@gmail.com>
Cc: "Michal Simek" <michal.simek@xilinx.com>,
	"Harini Katakam" <harini.katakam@xilinx.com>,
	"Sören Brinkmann" <soren.brinkmann@xilinx.com>,
	linux-gpio@vger.kernel.org,
	"Lars-Peter Clausen" <lars@metafoo.de>
Subject: [PATCH v2 2/2] gpio: zynq: Take bank offset into account when reporting a IRQ
Date: Mon, 18 Aug 2014 11:54:56 +0200	[thread overview]
Message-ID: <1408355696-9998-2-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1408355696-9998-1-git-send-email-lars@metafoo.de>

When looking up the IRQ the bank offset needs to be taken into account.
Otherwise interrupts for banks other than bank 0 get incorrectly reported as
interrupts for bank 0.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
Changes since v1:
	* Use lookup table instead of switch-case.
---
 drivers/gpio/gpio-zynq.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
index f440317..5db1af7 100644
--- a/drivers/gpio/gpio-zynq.c
+++ b/drivers/gpio/gpio-zynq.c
@@ -138,6 +138,13 @@ static inline void zynq_gpio_get_bank_pin(unsigned int pin_num,
 	}
 }
 
+static const unsigned int zynq_gpio_bank_offset[] = {
+	ZYNQ_GPIO_BANK0_PIN_MIN,
+	ZYNQ_GPIO_BANK1_PIN_MIN,
+	ZYNQ_GPIO_BANK2_PIN_MIN,
+	ZYNQ_GPIO_BANK3_PIN_MIN,
+};
+
 /**
  * zynq_gpio_get_value - Get the state of the specified pin of GPIO device
  * @chip:	gpio_chip instance to be worked on
@@ -461,6 +468,7 @@ static void zynq_gpio_handle_bank_irq(struct zynq_gpio *gpio,
 				      unsigned int bank_num,
 				      unsigned long pending)
 {
+	unsigned int bank_offset = zynq_gpio_bank_offset[bank_num];
 	struct irq_domain *irqdomain = gpio->chip.irqdomain;
 	int offset;
 
@@ -470,7 +478,7 @@ static void zynq_gpio_handle_bank_irq(struct zynq_gpio *gpio,
 	for_each_set_bit(offset, &pending, 32) {
 		unsigned int gpio_irq;
 
-		gpio_irq = irq_find_mapping(irqdomain, offset);
+		gpio_irq = irq_find_mapping(irqdomain, offset + bank_offset);
 		generic_handle_irq(gpio_irq);
 	}
 }
-- 
1.8.0


  reply	other threads:[~2014-08-18  9:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Lars-Peter Clausen [this message]
2014-08-18 16:28   ` [PATCH v2 2/2] gpio: zynq: Take bank offset into account when reporting a IRQ 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1408355696-9998-2-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=gnurou@gmail.com \
    --cc=harini.katakam@xilinx.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=soren.brinkmann@xilinx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).