public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Stephen Warren <swarren@nvidia.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Liam Girdwood <lrg@ti.com>, Chris Ball <cjb@laptop.org>,
	ccross@android.com, olof@lixom.net, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	alsa-devel@alsa-project.org, linux-mmc@vger.kernel.org,
	linux-tegra@vger.kernel.org
Subject: Re: [PATCH 1/3] irq: If an IRQ is a GPIO, request and configure it
Date: Fri, 2 Sep 2011 10:36:51 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.2.02.1109021027360.2723@ionos> (raw)
In-Reply-To: <1312498820-2275-2-git-send-email-swarren@nvidia.com>

On Thu, 4 Aug 2011, Stephen Warren wrote:

> Many IRQs are associated with GPIO pins. When the pin is used as an IRQ,
> it can't be used as anything else; it should be requested. Enhance the
> core interrupt code to call gpio_request() and gpio_direction_input() for
> any IRQ that is also a GPIO. This prevents duplication of these calls in
> each driver that uses an IRQ.

This is very much the wrong approach. If you think it through then the
irq setup code might end up with tons of other subsystem specific
setup thingies, e.g. PCI .....

The right thing to do is to add a irq_configure() function pointer to
the irq chip and provide a common function for gpios in gpiolib, which
is then used by the particular GPIO irq chip implementation.

Thanks,

	tglx
---
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 5951730..33ba4b8 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -265,6 +265,7 @@ static inline void irqd_clr_chained_irq_inprogress(struct irq_data *d)
  * struct irq_chip - hardware interrupt chip descriptor
  *
  * @name:		name for /proc/interrupts
+ * @irq_configure:	configure an interrupt (optional)
  * @irq_startup:	start up the interrupt (defaults to ->enable if NULL)
  * @irq_shutdown:	shut down the interrupt (defaults to ->disable if NULL)
  * @irq_enable:		enable the interrupt (defaults to chip->unmask if NULL)
@@ -289,9 +290,14 @@ static inline void irqd_clr_chained_irq_inprogress(struct irq_data *d)
  * @flags:		chip specific flags
  *
  * @release:		release function solely used by UML
+ *
+ * If @irq_configure is provided, it's called from setup_irq prior to
+ * enabling the interrupt. irq_configure should return 0 on success or
+ * an appropriate error code.
  */
 struct irq_chip {
 	const char	*name;
+	int		(*irq_configure)(struct irq_data *data);
 	unsigned int	(*irq_startup)(struct irq_data *data);
 	void		(*irq_shutdown)(struct irq_data *data);
 	void		(*irq_enable)(struct irq_data *data);
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 9b956fa..d5e6a58 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -999,6 +999,13 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
 	if (!shared) {
 		init_waitqueue_head(&desc->wait_for_threads);
 
+		/* Configure the interrupt */
+		if (desc->chip->irq_configure) {
+			ret = desc->chip->irq_configure(&desc->irq_data);
+			if (ret)
+				goto out_mask;
+		}
+
 		/* Setup the type (level, edge polarity) if configured: */
 		if (new->flags & IRQF_TRIGGER_MASK) {
 			ret = __irq_set_trigger(desc, irq,


  parent reply	other threads:[~2011-09-02  8:36 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-04 23:00 [RFC PATCH 0/3] If an IRQ is a GPIO, request and configure it Stephen Warren
     [not found] ` <1312498820-2275-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-08-04 23:00   ` [PATCH 1/3] irq: " Stephen Warren
2011-08-05  0:01     ` Mark Brown
     [not found]       ` <20110805000148.GB13321-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2011-08-05  3:53         ` Stephen Warren
2011-08-05  5:35           ` Mark Brown
     [not found]             ` <20110805053510.GA16956-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2011-08-05  8:06               ` Ben Dooks
2011-08-05  8:29                 ` Mark Brown
2011-08-05 15:29             ` Stephen Warren
2011-08-05 16:15               ` Mark Brown
2011-08-05  1:54     ` Rob Herring
2011-08-05  4:05       ` Stephen Warren
2011-08-05  7:58     ` Ben Dooks
2011-09-02  8:36     ` Thomas Gleixner [this message]
2011-09-02 15:24       ` Stephen Warren
     [not found]         ` <74CDBE0F657A3D45AFBB94109FB122FF04B327A55C-C7FfzLzN0UxDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2011-09-02 15:34           ` Stephen Warren
2011-09-02 15:50           ` Thomas Gleixner
2011-08-04 23:00   ` [PATCH 2/3] mmc: tegra: Don't gpio_request GPIOs used as IRQs Stephen Warren
2011-08-04 23:00   ` [PATCH 3/3] ASoC: jack_add_gpios: " Stephen Warren
2011-08-05  7:55   ` [RFC PATCH 0/3] If an IRQ is a GPIO, request and configure it Ben Dooks
2011-08-05  9:40 ` Russell King - ARM Linux
     [not found]   ` <20110805094017.GC20575-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2011-08-05 10:30     ` Ben Dooks
2011-08-05 20:25       ` Linus Walleij
2011-08-05 15:43   ` Stephen Warren
2011-08-05 19:15     ` Russell King - ARM Linux
2011-08-05 19:33       ` Stephen Warren
2011-08-05 21:40         ` Russell King - ARM Linux

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=alpine.LFD.2.02.1109021027360.2723@ionos \
    --to=tglx@linutronix.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=ccross@android.com \
    --cc=cjb@laptop.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=olof@lixom.net \
    --cc=swarren@nvidia.com \
    /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