* [PATCH v2] gpio: lock adnp IRQs when enabling them
@ 2013-11-26 10:05 Linus Walleij
2013-11-26 13:15 ` Grygorii Strashko
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2013-11-26 10:05 UTC (permalink / raw)
To: linux-gpio, Thierry Reding, Lars Poeschel
Cc: Alexandre Courbot, Linus Walleij
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.
Only compile tested on the lpc32xx.
Cc: Lars Poeschel <poeschel@lemonage.de>
Cc: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Use the .enable() callback from the irq_chip
- Call .unmask() from the .enable() callback to satisfy semantics.
---
drivers/gpio/gpio-adnp.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c
index b204033acaeb..3988ebc5a40e 100644
--- a/drivers/gpio/gpio-adnp.c
+++ b/drivers/gpio/gpio-adnp.c
@@ -408,6 +408,25 @@ static void adnp_irq_bus_unlock(struct irq_data *data)
mutex_unlock(&adnp->irq_lock);
}
+static void adnp_irq_enable(struct irq_data *data)
+{
+ struct adnp *adnp = irq_data_get_irq_chip_data(data);
+
+ if (gpio_lock_as_irq(&adnp->gpio, data->hwirq))
+ dev_err(adnp->gpio.dev,
+ "unable to lock HW IRQ %lu for IRQ\n",
+ data->hwirq);
+ /* Satisfy the .enable semantics by unmasking the line */
+ adnp_irq_unmask(data);
+}
+
+static void adnp_irq_disable(struct irq_data *data)
+{
+ struct adnp *adnp = irq_data_get_irq_chip_data(data);
+
+ gpio_unlock_as_irq(&adnp->gpio, data->hwirq);
+}
+
static struct irq_chip adnp_irq_chip = {
.name = "gpio-adnp",
.irq_mask = adnp_irq_mask,
@@ -415,6 +434,8 @@ static struct irq_chip adnp_irq_chip = {
.irq_set_type = adnp_irq_set_type,
.irq_bus_lock = adnp_irq_bus_lock,
.irq_bus_sync_unlock = adnp_irq_bus_unlock,
+ .irq_enable = adnp_irq_enable,
+ .irq_disable = adnp_irq_disable,
};
static int adnp_irq_map(struct irq_domain *domain, unsigned int irq,
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] gpio: lock adnp IRQs when enabling them
2013-11-26 10:05 [PATCH v2] gpio: lock adnp IRQs when enabling them Linus Walleij
@ 2013-11-26 13:15 ` Grygorii Strashko
2013-11-29 9:49 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Grygorii Strashko @ 2013-11-26 13:15 UTC (permalink / raw)
To: Linus Walleij, linux-gpio, Thierry Reding, Lars Poeschel
Cc: Alexandre Courbot
On 11/26/2013 12:05 PM, Linus Walleij wrote:
> 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.
>
> Only compile tested on the lpc32xx.
>
> Cc: Lars Poeschel <poeschel@lemonage.de>
> Cc: Thierry Reding <thierry.reding@avionic-design.de>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - Use the .enable() callback from the irq_chip
> - Call .unmask() from the .enable() callback to satisfy semantics.
> ---
> drivers/gpio/gpio-adnp.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c
> index b204033acaeb..3988ebc5a40e 100644
> --- a/drivers/gpio/gpio-adnp.c
> +++ b/drivers/gpio/gpio-adnp.c
> @@ -408,6 +408,25 @@ static void adnp_irq_bus_unlock(struct irq_data *data)
> mutex_unlock(&adnp->irq_lock);
> }
>
> +static void adnp_irq_enable(struct irq_data *data)
> +{
> + struct adnp *adnp = irq_data_get_irq_chip_data(data);
> +
> + if (gpio_lock_as_irq(&adnp->gpio, data->hwirq))
> + dev_err(adnp->gpio.dev,
> + "unable to lock HW IRQ %lu for IRQ\n",
> + data->hwirq);
> + /* Satisfy the .enable semantics by unmasking the line */
> + adnp_irq_unmask(data);
> +}
> +
> +static void adnp_irq_disable(struct irq_data *data)
> +{
> + struct adnp *adnp = irq_data_get_irq_chip_data(data);
> +
> + gpio_unlock_as_irq(&adnp->gpio, data->hwirq);
> +}
> +
> static struct irq_chip adnp_irq_chip = {
> .name = "gpio-adnp",
> .irq_mask = adnp_irq_mask,
> @@ -415,6 +434,8 @@ static struct irq_chip adnp_irq_chip = {
> .irq_set_type = adnp_irq_set_type,
> .irq_bus_lock = adnp_irq_bus_lock,
> .irq_bus_sync_unlock = adnp_irq_bus_unlock,
> + .irq_enable = adnp_irq_enable,
> + .irq_disable = adnp_irq_disable,
.irq_startup/irq_shutdown ?
> };
>
> static int adnp_irq_map(struct irq_domain *domain, unsigned int irq,
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] gpio: lock adnp IRQs when enabling them
2013-11-26 13:15 ` Grygorii Strashko
@ 2013-11-29 9:49 ` Linus Walleij
0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2013-11-29 9:49 UTC (permalink / raw)
To: Grygorii Strashko
Cc: linux-gpio@vger.kernel.org, Thierry Reding, Lars Poeschel,
Alexandre Courbot
On Tue, Nov 26, 2013 at 2:15 PM, Grygorii Strashko
<grygorii.strashko@ti.com> wrote:
> On 11/26/2013 12:05 PM, Linus Walleij wrote:
>>
>> 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.
>>
(...)
>> + .irq_enable = adnp_irq_enable,
>> + .irq_disable = adnp_irq_disable,
>
>
> .irq_startup/irq_shutdown ?
Sorry I was in a confused middle-ground when doing this,
not having figured out whether to use enable/disable or
startup/shutdown. Sent a v3 using startup/shutdown.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-11-29 9:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-26 10:05 [PATCH v2] gpio: lock adnp IRQs when enabling them Linus Walleij
2013-11-26 13:15 ` Grygorii Strashko
2013-11-29 9:49 ` 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).