950-0128-gpiolib-Don-t-prevent-IRQ-usage-of-output-GPIOs.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. From 122b21149cada59805040895f3d679ceb0e00063 Mon Sep 17 00:00:00 2001
  2. From: Phil Elwell <[email protected]>
  3. Date: Tue, 24 Apr 2018 14:42:27 +0100
  4. Subject: [PATCH] gpiolib: Don't prevent IRQ usage of output GPIOs
  5. Upstream Linux deems using output GPIOs to generate IRQs as a bogus
  6. use case, even though the BCM2835 GPIO controller is capable of doing
  7. so. A number of users would like to make use of this facility, so
  8. disable the checks.
  9. See: https://github.com/raspberrypi/linux/issues/2527
  10. Signed-off-by: Phil Elwell <[email protected]>
  11. ---
  12. drivers/gpio/gpiolib.c | 8 +++++---
  13. 1 file changed, 5 insertions(+), 3 deletions(-)
  14. --- a/drivers/gpio/gpiolib.c
  15. +++ b/drivers/gpio/gpiolib.c
  16. @@ -55,6 +55,8 @@
  17. #define extra_checks 0
  18. #endif
  19. +#define dont_test_bit(b,d) (0)
  20. +
  21. /* Device and char device-related information */
  22. static DEFINE_IDA(gpio_ida);
  23. static dev_t gpio_devt;
  24. @@ -3091,8 +3093,8 @@ int gpiod_direction_output(struct gpio_d
  25. value = !!value;
  26. /* GPIOs used for enabled IRQs shall not be set as output */
  27. - if (test_bit(FLAG_USED_AS_IRQ, &desc->flags) &&
  28. - test_bit(FLAG_IRQ_IS_ENABLED, &desc->flags)) {
  29. + if (dont_test_bit(FLAG_USED_AS_IRQ, &desc->flags) &&
  30. + dont_test_bit(FLAG_IRQ_IS_ENABLED, &desc->flags)) {
  31. gpiod_err(desc,
  32. "%s: tried to set a GPIO tied to an IRQ as output\n",
  33. __func__);
  34. @@ -3895,8 +3897,8 @@ int gpiochip_lock_as_irq(struct gpio_chi
  35. }
  36. /* To be valid for IRQ the line needs to be input or open drain */
  37. - if (test_bit(FLAG_IS_OUT, &desc->flags) &&
  38. - !test_bit(FLAG_OPEN_DRAIN, &desc->flags)) {
  39. + if (dont_test_bit(FLAG_IS_OUT, &desc->flags) &&
  40. + !dont_test_bit(FLAG_OPEN_DRAIN, &desc->flags)) {
  41. chip_err(chip,
  42. "%s: tried to flag a GPIO set as output for IRQ\n",
  43. __func__);