[PATCH] gpio: max732x: allow IRQF_SHARED when hardware mask is available

From: Marc Zyngier
Date: Mon Mar 22 2010 - 03:28:30 EST


Signed-off-by: Marc Zyngier <maz@xxxxxxxxxxxxxxx>
---
drivers/gpio/max732x.c | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/max732x.c b/drivers/gpio/max732x.c
index 647ae6f..07a9405 100644
--- a/drivers/gpio/max732x.c
+++ b/drivers/gpio/max732x.c
@@ -293,6 +293,14 @@ static int max732x_readw(struct max732x_chip *chip, uint16_t *val)
return 0;
}

+static inline int max732x_has_irqmask(struct max732x_chip *chip)
+{
+ if (chip->irq_features == INT_NO_MASK)
+ return 0;
+
+ return 1;
+}
+
static void max732x_irq_update_mask(struct max732x_chip *chip)
{
uint16_t msg;
@@ -302,7 +310,7 @@ static void max732x_irq_update_mask(struct max732x_chip *chip)

chip->irq_mask = chip->irq_mask_cur;

- if (chip->irq_features == INT_NO_MASK)
+ if (!max732x_has_irqmask(chip))
return;

mutex_lock(&chip->lock);
@@ -439,8 +447,14 @@ static irqreturn_t max732x_irq_handler(int irq, void *devid)

pending = max732x_irq_pending(chip);

- if (!pending)
+ if (!pending) {
+ /* if we have a hardware mask, then the interrupt must
+ * come from another device */
+ if (max732x_has_irqmask(chip))
+ return IRQ_NONE;
+
return IRQ_HANDLED;
+ }

do {
level = __ffs(pending);
@@ -462,6 +476,7 @@ static int max732x_irq_setup(struct max732x_chip *chip,

if (pdata->irq_base && has_irq != INT_NONE) {
int lvl;
+ int irq_flags;

chip->irq_base = pdata->irq_base;
chip->irq_features = has_irq;
@@ -484,10 +499,14 @@ static int max732x_irq_setup(struct max732x_chip *chip,
#endif
}

+ irq_flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT;
+ if (max732x_has_irqmask(chip))
+ irq_flags |= IRQF_SHARED;
+
ret = request_threaded_irq(client->irq,
NULL,
max732x_irq_handler,
- IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+ irq_flags,
dev_name(&client->dev), chip);
if (ret) {
dev_err(&client->dev, "failed to request irq %d\n",
--
1.7.0.2



--
I'm the slime oozin' out from your TV set...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/