linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Cohen <david.a.cohen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
Cc: Linus Walleij
	<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH] gpio: tegra: use new gpio_lock_as_irq() API
Date: Wed, 16 Oct 2013 20:45:45 -0700	[thread overview]
Message-ID: <525F5D69.60906@linux.intel.com> (raw)
In-Reply-To: <1381951533-18179-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>

Hi Stephen,

On 10/16/2013 12:25 PM, Stephen Warren wrote:
> From: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>
> Whenever an IRQ is claimed or freed, call gpio_lock_as_irq() or
> gpio_unlock_as_irq() on the associated GPIO, to prevent that GPIO from
> being configured in a manner incompatible with an interrupt.
>
> Signed-off-by: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
>   drivers/gpio/gpio-tegra.c | 18 ++++++++++++++++++
>   1 file changed, 18 insertions(+)
>
> diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
> index 9a62672..cfd3b90 100644
> --- a/drivers/gpio/gpio-tegra.c
> +++ b/drivers/gpio/gpio-tegra.c
> @@ -75,6 +75,7 @@ struct tegra_gpio_bank {
>   #endif
>   };
>
> +static struct device *dev;
>   static struct irq_domain *irq_domain;
>   static void __iomem *regs;
>   static u32 tegra_gpio_bank_count;
> @@ -205,6 +206,7 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type)
>   	int lvl_type;
>   	int val;
>   	unsigned long flags;
> +	int ret;
>
>   	switch (type & IRQ_TYPE_SENSE_MASK) {
>   	case IRQ_TYPE_EDGE_RISING:
> @@ -231,6 +233,12 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type)
>   		return -EINVAL;
>   	}
>
> +	ret = gpio_lock_as_irq(&tegra_gpio_chip, gpio);
> +	if (ret) {
> +		dev_err(dev, "unable to lock Tegra GPIO %d as IRQ\n", gpio);

As a suggestion, you could add a pointer to dev on tegra gpio priv data
and recover it using ira_data_get_irq_chip_data(), instead of using
static file-scope variable.

Br, David Cohen

  parent reply	other threads:[~2013-10-17  3:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-16 19:25 [PATCH] gpio: tegra: use new gpio_lock_as_irq() API Stephen Warren
2013-10-17  3:25 ` Javier Martinez Canillas
     [not found] ` <1381951533-18179-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-10-17  3:45   ` David Cohen [this message]
2013-10-17  4:25     ` Stephen Warren
     [not found]       ` <525F66B1.9020903-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-10-17  8:53         ` Linus Walleij
2013-10-17  8:52   ` 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=525F5D69.60906@linux.intel.com \
    --to=david.a.cohen-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
    --cc=swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.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).