diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2013-11-20 04:16:54 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-12-04 08:46:39 -0500 |
commit | 0dc616236961e39e0fefecb4301f9e4632e4a511 (patch) | |
tree | 051a364a6d83a1e779577d325aef7a64e054b8fc /drivers | |
parent | db6b3ad1772e0e0e82c52d6337378e79da2effad (diff) |
gpio: em: lock IRQs when starting them
This uses the new API for tagging GPIO lines as in use by
IRQs. This enforces a few semantic checks on how the underlying
GPIO line is used.
Also assign the gpio_chip.dev pointer to be used for error
messages.
ChangeLog v1->v2:
- Satisfy implicit semantics by calling .enable and .disable
callbacks in the startup/shutdown callbacks.
Cc: Ian Molton <ian.molton@codethink.co.uk>
Cc: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpio/gpio-em.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c index ec190361bf2e..1cc53516e8b4 100644 --- a/drivers/gpio/gpio-em.c +++ b/drivers/gpio/gpio-em.c | |||
@@ -99,6 +99,27 @@ static void em_gio_irq_enable(struct irq_data *d) | |||
99 | em_gio_write(p, GIO_IEN, BIT(irqd_to_hwirq(d))); | 99 | em_gio_write(p, GIO_IEN, BIT(irqd_to_hwirq(d))); |
100 | } | 100 | } |
101 | 101 | ||
102 | static unsigned int em_gio_irq_startup(struct irq_data *d) | ||
103 | { | ||
104 | struct em_gio_priv *p = irq_data_get_irq_chip_data(d); | ||
105 | |||
106 | if (gpio_lock_as_irq(&p->gpio_chip, irqd_to_hwirq(d))) | ||
107 | dev_err(p->gpio_chip.dev, | ||
108 | "unable to lock HW IRQ %lu for IRQ\n", | ||
109 | irqd_to_hwirq(d)); | ||
110 | em_gio_irq_enable(d); | ||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | static void em_gio_irq_shutdown(struct irq_data *d) | ||
115 | { | ||
116 | struct em_gio_priv *p = irq_data_get_irq_chip_data(d); | ||
117 | |||
118 | em_gio_irq_disable(d); | ||
119 | gpio_unlock_as_irq(&p->gpio_chip, irqd_to_hwirq(d)); | ||
120 | } | ||
121 | |||
122 | |||
102 | #define GIO_ASYNC(x) (x + 8) | 123 | #define GIO_ASYNC(x) (x + 8) |
103 | 124 | ||
104 | static unsigned char em_gio_sense_table[IRQ_TYPE_SENSE_MASK + 1] = { | 125 | static unsigned char em_gio_sense_table[IRQ_TYPE_SENSE_MASK + 1] = { |
@@ -328,6 +349,7 @@ static int em_gio_probe(struct platform_device *pdev) | |||
328 | gpio_chip->request = em_gio_request; | 349 | gpio_chip->request = em_gio_request; |
329 | gpio_chip->free = em_gio_free; | 350 | gpio_chip->free = em_gio_free; |
330 | gpio_chip->label = name; | 351 | gpio_chip->label = name; |
352 | gpio_chip->dev = &pdev->dev; | ||
331 | gpio_chip->owner = THIS_MODULE; | 353 | gpio_chip->owner = THIS_MODULE; |
332 | gpio_chip->base = pdata->gpio_base; | 354 | gpio_chip->base = pdata->gpio_base; |
333 | gpio_chip->ngpio = pdata->number_of_pins; | 355 | gpio_chip->ngpio = pdata->number_of_pins; |
@@ -339,6 +361,8 @@ static int em_gio_probe(struct platform_device *pdev) | |||
339 | irq_chip->irq_enable = em_gio_irq_enable; | 361 | irq_chip->irq_enable = em_gio_irq_enable; |
340 | irq_chip->irq_disable = em_gio_irq_disable; | 362 | irq_chip->irq_disable = em_gio_irq_disable; |
341 | irq_chip->irq_set_type = em_gio_irq_set_type; | 363 | irq_chip->irq_set_type = em_gio_irq_set_type; |
364 | irq_chip->irq_startup = em_gio_irq_startup; | ||
365 | irq_chip->irq_shutdown = em_gio_irq_shutdown; | ||
342 | irq_chip->flags = IRQCHIP_SKIP_SET_WAKE; | 366 | irq_chip->flags = IRQCHIP_SKIP_SET_WAKE; |
343 | 367 | ||
344 | p->irq_domain = irq_domain_add_simple(pdev->dev.of_node, | 368 | p->irq_domain = irq_domain_add_simple(pdev->dev.of_node, |