Thread (26 messages) 26 messages, 8 authors, 2011-09-02

RE: [PATCH 1/3] irq: If an IRQ is a GPIO, request and configure it

From: Stephen Warren <hidden>
Date: 2011-08-05 15:30:02
Also in: alsa-devel, linux-arm-kernel, linux-tegra, lkml

Mark Brown wrote at Thursday, August 04, 2011 11:35 PM:
On Thu, Aug 04, 2011 at 08:53:34PM -0700, Stephen Warren wrote:
quoted
Well, things break. This is essentially the problem I was describing in
the PATCH 0 email, just with a slightly different motivation.
There's a bunch of existing code using that idiom.
Certainly.
quoted
I suppose that an alternative here would be to simply ignore any errors
from gpio_request. This might have the benefit of removing the need for
the other two patches I posted in the series. However, it seems a little
dirty; one benefit of the IRQ code calling gpio_request and honoring
errors would be to detect when some completely unrelated code had a bug
and had called gpio_request on the GPIO before. Such detection would be
non-existent if we don't error out on gpio_request. Perhaps some mechanism
is needed to indicate that the driver has explicitly already called
gpio_request for a legitimate shared purpose, and only then ignore
errors?
But it's not a bug to use a GPIO as an IRQ source, otherwise we wouldn't
have gpio_to_irq() in the first place.
True, but I think there are two cases:

1) Some code legitimately uses a pin as both a GPIO and IRQ, and is fully
cognizant of the fact, just like in your example -> no bug.

2) Two pieces of unrelated code somehow accidentally get a GPIO and IRQ
number that map to the same resource, e.g. due to incorrect board files or
Device Tree content. This is probably a bug, but ends up looking exactly
the same as far as the IRQ code's gpio_request call failing in the patch I
posted.
Feels like we need a backchannel
between gpiolib and the IRQ code to do this.  Or perhaps the drivers
that implement this should be taking care of setting up the GPIO mode?
-- 
nvpublic
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help