From: William Breathitt Gray <vilhelm.gray@gmail.com>
To: linus.walleij@linaro.org, gnurou@gmail.com
Cc: linux-gpio@vger.kernel.org
Subject: [PATCH] gpio: 104-idi-48: Clear pending interrupt once in IRQ handler
Date: Tue, 15 Dec 2015 18:52:44 -0500 [thread overview]
Message-ID: <20151215235244.GA4401@sophia> (raw)
Performing a read operation on the IRQ Status register will clear the
IRQ latch. Since a read operation on the IRQ Status register must be
performed in the IRQ handler in order to determine if the IRQ was in
fact generated by the device, the IRQ latch is consequently cleared by
the IRQ handler. A spinlock is used to guarantee that each IRQ is
serviced in the order it was received.
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
drivers/gpio/gpio-104-idi-48.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
index b5c6934..296dbd4 100644
--- a/drivers/gpio/gpio-104-idi-48.c
+++ b/drivers/gpio/gpio-104-idi-48.c
@@ -36,6 +36,7 @@ MODULE_PARM_DESC(idi_48_irq, "ACCES 104-IDI-48 interrupt line number");
* struct idi_48_gpio - GPIO device private data structure
* @chip: instance of the gpio_chip
* @lock: synchronization lock to prevent I/O race conditions
+ * @ack_lock: synchronization lock to prevent IRQ handler race conditions
* @irq_mask: input bits affected by interrupts
* @base: base port address of the GPIO device
* @extent: extent of port address region of the GPIO device
@@ -45,6 +46,7 @@ MODULE_PARM_DESC(idi_48_irq, "ACCES 104-IDI-48 interrupt line number");
struct idi_48_gpio {
struct gpio_chip chip;
spinlock_t lock;
+ spinlock_t ack_lock;
unsigned char irq_mask[6];
unsigned base;
unsigned extent;
@@ -89,15 +91,6 @@ static int idi_48_gpio_get(struct gpio_chip *chip, unsigned offset)
static void idi_48_irq_ack(struct irq_data *data)
{
- struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
- struct idi_48_gpio *const idi48gpio = to_idi48gpio(chip);
- unsigned long flags;
-
- spin_lock_irqsave(&idi48gpio->lock, flags);
-
- inb(idi48gpio->base + 7);
-
- spin_unlock_irqrestore(&idi48gpio->lock, flags);
}
static void idi_48_irq_mask(struct irq_data *data)
@@ -192,6 +185,8 @@ static irqreturn_t idi_48_irq_handler(int irq, void *dev_id)
unsigned long gpio;
struct gpio_chip *const chip = &idi48gpio->chip;
+ spin_lock(&idi48gpio->ack_lock);
+
spin_lock(&idi48gpio->lock);
cos_status = inb(idi48gpio->base + 7);
@@ -199,8 +194,10 @@ static irqreturn_t idi_48_irq_handler(int irq, void *dev_id)
spin_unlock(&idi48gpio->lock);
/* IRQ Status (bit 6) is active low (0 = IRQ generated by device) */
- if (cos_status & BIT(6))
+ if (cos_status & BIT(6)) {
+ spin_unlock(&idi48gpio->ack_lock);
return IRQ_NONE;
+ }
/* Bit 0-5 indicate which Change-Of-State boundary triggered the IRQ */
cos_status &= 0x3F;
@@ -216,6 +213,8 @@ static irqreturn_t idi_48_irq_handler(int irq, void *dev_id)
}
}
+ spin_unlock(&idi48gpio->ack_lock);
+
return IRQ_HANDLED;
}
--
2.4.10
next reply other threads:[~2015-12-15 23:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-15 23:52 William Breathitt Gray [this message]
2015-12-22 9:20 ` [PATCH] gpio: 104-idi-48: Clear pending interrupt once in IRQ handler 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=20151215235244.GA4401@sophia \
--to=vilhelm.gray@gmail.com \
--cc=gnurou@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
/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).