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>
This commit is contained in:
committed by
Linus Torvalds
parent
2f8d11971b
commit
0f6d504e73
@@ -1010,6 +1010,24 @@ int __gpio_cansleep(unsigned gpio)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__gpio_cansleep);
|
||||
|
||||
/**
|
||||
* __gpio_to_irq() - return the IRQ corresponding to a GPIO
|
||||
* @gpio: gpio whose IRQ will be returned (already requested)
|
||||
* Context: any
|
||||
*
|
||||
* This is used directly or indirectly to implement gpio_to_irq().
|
||||
* It returns the number of the IRQ signaled by this (input) GPIO,
|
||||
* or a negative errno.
|
||||
*/
|
||||
int __gpio_to_irq(unsigned gpio)
|
||||
{
|
||||
struct gpio_chip *chip;
|
||||
|
||||
chip = gpio_to_chip(gpio);
|
||||
return chip->to_irq ? chip->to_irq(chip, gpio - chip->base) : -ENXIO;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__gpio_to_irq);
|
||||
|
||||
|
||||
|
||||
/* There's no value in making it easy to inline GPIO calls that may sleep.
|
||||
|
Reference in New Issue
Block a user