aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2008-10-16 01:03:14 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 14:21:40 -0400
commit0f6d504e73b49374c6093efe6aa60ab55058248a (patch)
tree414c9e591ba23b2126bc9cad4e0efb1b60693b2d /drivers
parent2f8d11971b9f54362437ce70f4d1911f0996d542 (diff)
gpiolib: gpio_to_irq() hooks
Add a new gpiolib mechanism: gpio_chip instances can provide mappings between their (input) GPIOs and any associated IRQs. This makes it easier for platforms to support IRQs that are provided by board-specific external chips instead of as part of their core (such as SOC-integrated GPIOs). Also update the irq_to_gpio() description, saying to avoid it because it's not always supported. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/gpiolib.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 317004fd94fb..29a7e6b1be5d 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1010,6 +1010,24 @@ int __gpio_cansleep(unsigned gpio)
1010} 1010}
1011EXPORT_SYMBOL_GPL(__gpio_cansleep); 1011EXPORT_SYMBOL_GPL(__gpio_cansleep);
1012 1012
1013/**
1014 * __gpio_to_irq() - return the IRQ corresponding to a GPIO
1015 * @gpio: gpio whose IRQ will be returned (already requested)
1016 * Context: any
1017 *
1018 * This is used directly or indirectly to implement gpio_to_irq().
1019 * It returns the number of the IRQ signaled by this (input) GPIO,
1020 * or a negative errno.
1021 */
1022int __gpio_to_irq(unsigned gpio)
1023{
1024 struct gpio_chip *chip;
1025
1026 chip = gpio_to_chip(gpio);
1027 return chip->to_irq ? chip->to_irq(chip, gpio - chip->base) : -ENXIO;
1028}
1029EXPORT_SYMBOL_GPL(__gpio_to_irq);
1030
1013 1031
1014 1032
1015/* There's no value in making it easy to inline GPIO calls that may sleep. 1033/* There's no value in making it easy to inline GPIO calls that may sleep.