diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2013-09-24 05:54:38 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-10-16 03:59:54 -0400 |
commit | d468bf9ecaabd3bf3a6134e5a369ced82b1d1ca1 (patch) | |
tree | 452eaf82c5c50a4673ccd5fccdc1407b1243d03d /include | |
parent | d27e06ac5dcf60d5502269e1875bcb0f05f1b1c1 (diff) |
gpio: add API to be strict about GPIO IRQ usage
It is currently often possible in many GPIO drivers to request
a GPIO line to be used as IRQ after calling gpio_to_irq() and,
as the gpiolib is not aware of this, set the same line to
output and start driving it, with undesired side effects.
As it is a bogus usage scenario to request a line flagged as
output to used as IRQ, we introduce APIs to let gpiolib track
the use of a line as IRQ, and also set this flag from the
userspace ABI.
The API is symmetric so that lines can also be flagged from
.irq_enable() and unflagged from IRQ by .irq_disable().
The debugfs file is altered so that we see if a line is
reserved for IRQ.
Cc: Enric Balletbo i Serra <eballetbo@gmail.com>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/gpio.h | 3 | ||||
-rw-r--r-- | include/linux/gpio.h | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index bde646995d10..b309a5c0019e 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h | |||
@@ -192,6 +192,9 @@ extern int __gpio_cansleep(unsigned gpio); | |||
192 | 192 | ||
193 | extern int __gpio_to_irq(unsigned gpio); | 193 | extern int __gpio_to_irq(unsigned gpio); |
194 | 194 | ||
195 | extern int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset); | ||
196 | extern void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset); | ||
197 | |||
195 | extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); | 198 | extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); |
196 | extern int gpio_request_array(const struct gpio *array, size_t num); | 199 | extern int gpio_request_array(const struct gpio *array, size_t num); |
197 | extern void gpio_free_array(const struct gpio *array, size_t num); | 200 | extern void gpio_free_array(const struct gpio *array, size_t num); |
diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 552e3f46e4a3..a06ec3e85ba3 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h | |||
@@ -204,6 +204,18 @@ static inline int gpio_to_irq(unsigned gpio) | |||
204 | return -EINVAL; | 204 | return -EINVAL; |
205 | } | 205 | } |
206 | 206 | ||
207 | static inline int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset) | ||
208 | { | ||
209 | WARN_ON(1); | ||
210 | return -EINVAL; | ||
211 | } | ||
212 | |||
213 | static inline void gpio_unlock_as_irq(struct gpio_chip *chip, | ||
214 | unsigned int offset) | ||
215 | { | ||
216 | WARN_ON(1); | ||
217 | } | ||
218 | |||
207 | static inline int irq_to_gpio(unsigned irq) | 219 | static inline int irq_to_gpio(unsigned irq) |
208 | { | 220 | { |
209 | /* irq can never have been returned from gpio_to_irq() */ | 221 | /* irq can never have been returned from gpio_to_irq() */ |