linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] gpio: bcm-kona: lock IRQs when starting them
@ 2013-11-26 10:11 Linus Walleij
  2013-11-26 11:04 ` Javier Martinez Canillas
  2013-11-26 21:04 ` Markus Mayer
  0 siblings, 2 replies; 3+ messages in thread
From: Linus Walleij @ 2013-11-26 10:11 UTC (permalink / raw)
  To: linux-gpio, Markus Mayer
  Cc: Alexandre Courbot, Linus Walleij, Christian Daudt,
	Grygorii Strashko, Javier Martinez Canillas

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.

Cc: Markus Mayer <markus.mayer@linaro.org>
Cc: Christian Daudt <csd@broadcom.com>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Javier Martinez Canillas <javier@dowhile0.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Make sure we call .unmask() and .mask() functions from the
  .startup() and .shutdown() callbacks so the implicit semantics
  are satisfied.
---
 drivers/gpio/gpio-bcm-kona.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
index 72c927dc3be1..3437414eaef2 100644
--- a/drivers/gpio/gpio-bcm-kona.c
+++ b/drivers/gpio/gpio-bcm-kona.c
@@ -449,12 +449,34 @@ static void bcm_kona_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
 	chained_irq_exit(chip, desc);
 }
 
+static unsigned int bcm_kona_gpio_irq_startup(struct irq_data *d)
+{
+	struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d);
+
+	if (gpio_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq))
+		dev_err(kona_gpio->gpio_chip.dev,
+			"unable to lock HW IRQ %lu for IRQ\n",
+			d->hwirq);
+	bcm_kona_gpio_irq_unmask(d);
+	return 0;
+}
+
+static void bcm_kona_gpio_irq_shutdown(struct irq_data *d)
+{
+	struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d);
+
+	bcm_kona_gpio_irq_mask(d);
+	gpio_unlock_as_irq(&kona_gpio->gpio_chip, d->hwirq);
+}
+
 static struct irq_chip bcm_gpio_irq_chip = {
 	.name = "bcm-kona-gpio",
 	.irq_ack = bcm_kona_gpio_irq_ack,
 	.irq_mask = bcm_kona_gpio_irq_mask,
 	.irq_unmask = bcm_kona_gpio_irq_unmask,
 	.irq_set_type = bcm_kona_gpio_irq_set_type,
+	.irq_startup = bcm_kona_gpio_irq_startup,
+	.irq_shutdown = bcm_kona_gpio_irq_shutdown,
 };
 
 static struct __initconst of_device_id bcm_kona_gpio_of_match[] = {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] gpio: bcm-kona: lock IRQs when starting them
  2013-11-26 10:11 [PATCH v2] gpio: bcm-kona: lock IRQs when starting them Linus Walleij
@ 2013-11-26 11:04 ` Javier Martinez Canillas
  2013-11-26 21:04 ` Markus Mayer
  1 sibling, 0 replies; 3+ messages in thread
From: Javier Martinez Canillas @ 2013-11-26 11:04 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Linux GPIO List, Markus Mayer, Alexandre Courbot, Christian Daudt,
	Grygorii Strashko

On Tue, Nov 26, 2013 at 11:11 AM, Linus Walleij
<linus.walleij@linaro.org> 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.
>
> Cc: Markus Mayer <markus.mayer@linaro.org>
> Cc: Christian Daudt <csd@broadcom.com>
> Cc: Grygorii Strashko <grygorii.strashko@ti.com>
> Cc: Javier Martinez Canillas <javier@dowhile0.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - Make sure we call .unmask() and .mask() functions from the
>   .startup() and .shutdown() callbacks so the implicit semantics
>   are satisfied.
> ---
>  drivers/gpio/gpio-bcm-kona.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
> index 72c927dc3be1..3437414eaef2 100644
> --- a/drivers/gpio/gpio-bcm-kona.c
> +++ b/drivers/gpio/gpio-bcm-kona.c
> @@ -449,12 +449,34 @@ static void bcm_kona_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
>         chained_irq_exit(chip, desc);
>  }
>
> +static unsigned int bcm_kona_gpio_irq_startup(struct irq_data *d)
> +{
> +       struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d);
> +
> +       if (gpio_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq))
> +               dev_err(kona_gpio->gpio_chip.dev,
> +                       "unable to lock HW IRQ %lu for IRQ\n",
> +                       d->hwirq);
> +       bcm_kona_gpio_irq_unmask(d);
> +       return 0;
> +}
> +
> +static void bcm_kona_gpio_irq_shutdown(struct irq_data *d)
> +{
> +       struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d);
> +
> +       bcm_kona_gpio_irq_mask(d);
> +       gpio_unlock_as_irq(&kona_gpio->gpio_chip, d->hwirq);
> +}
> +
>  static struct irq_chip bcm_gpio_irq_chip = {
>         .name = "bcm-kona-gpio",
>         .irq_ack = bcm_kona_gpio_irq_ack,
>         .irq_mask = bcm_kona_gpio_irq_mask,
>         .irq_unmask = bcm_kona_gpio_irq_unmask,
>         .irq_set_type = bcm_kona_gpio_irq_set_type,
> +       .irq_startup = bcm_kona_gpio_irq_startup,
> +       .irq_shutdown = bcm_kona_gpio_irq_shutdown,
>  };
>
>  static struct __initconst of_device_id bcm_kona_gpio_of_match[] = {
> --
> 1.8.3.1
>

Looks good to me now.

Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] gpio: bcm-kona: lock IRQs when starting them
  2013-11-26 10:11 [PATCH v2] gpio: bcm-kona: lock IRQs when starting them Linus Walleij
  2013-11-26 11:04 ` Javier Martinez Canillas
@ 2013-11-26 21:04 ` Markus Mayer
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Mayer @ 2013-11-26 21:04 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Linux GPIO List, Alexandre Courbot, Grygorii Strashko,
	Javier Martinez Canillas, Christian Daudt

On 26 November 2013 02:11, Linus Walleij <linus.walleij@linaro.org> 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.
>
> Cc: Markus Mayer <markus.mayer@linaro.org>
> Cc: Christian Daudt <csd@broadcom.com>

Please use Christian Daudt <bcm@fixthebug.org>. I fixed the e-mail
address in this thread.

> Cc: Grygorii Strashko <grygorii.strashko@ti.com>
> Cc: Javier Martinez Canillas <javier@dowhile0.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - Make sure we call .unmask() and .mask() functions from the
>   .startup() and .shutdown() callbacks so the implicit semantics
>   are satisfied.
> ---
>  drivers/gpio/gpio-bcm-kona.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
> index 72c927dc3be1..3437414eaef2 100644
> --- a/drivers/gpio/gpio-bcm-kona.c
> +++ b/drivers/gpio/gpio-bcm-kona.c
> @@ -449,12 +449,34 @@ static void bcm_kona_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
>         chained_irq_exit(chip, desc);
>  }
>
> +static unsigned int bcm_kona_gpio_irq_startup(struct irq_data *d)
> +{
> +       struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d);
> +
> +       if (gpio_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq))
> +               dev_err(kona_gpio->gpio_chip.dev,
> +                       "unable to lock HW IRQ %lu for IRQ\n",
> +                       d->hwirq);
> +       bcm_kona_gpio_irq_unmask(d);
> +       return 0;
> +}
> +
> +static void bcm_kona_gpio_irq_shutdown(struct irq_data *d)
> +{
> +       struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d);
> +
> +       bcm_kona_gpio_irq_mask(d);
> +       gpio_unlock_as_irq(&kona_gpio->gpio_chip, d->hwirq);
> +}
> +
>  static struct irq_chip bcm_gpio_irq_chip = {
>         .name = "bcm-kona-gpio",
>         .irq_ack = bcm_kona_gpio_irq_ack,
>         .irq_mask = bcm_kona_gpio_irq_mask,
>         .irq_unmask = bcm_kona_gpio_irq_unmask,
>         .irq_set_type = bcm_kona_gpio_irq_set_type,
> +       .irq_startup = bcm_kona_gpio_irq_startup,
> +       .irq_shutdown = bcm_kona_gpio_irq_shutdown,
>  };
>
>  static struct __initconst of_device_id bcm_kona_gpio_of_match[] = {
> --
> 1.8.3.1
>

I verified that cd-gpio is still working with this change, therefore:

Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Tested-by: Markus Mayer <markus.mayer@linaro.org>

-- 
Markus Mayer
Broadcom Landing Team

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-26 21:04 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:11 [PATCH v2] gpio: bcm-kona: lock IRQs when starting them Linus Walleij
2013-11-26 11:04 ` Javier Martinez Canillas
2013-11-26 21:04 ` Markus Mayer

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).