summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2018-09-14 10:36:39 +0200
committerLinus Walleij <linus.walleij@linaro.org>2018-09-17 17:24:02 +0200
commit171948ea33e14dd1e49ba6439eabe822449ffd21 (patch)
treeb50c3e32005b558145057e97770a287cd4b8d294 /drivers/gpio/gpiolib.c
parentgpiolib: use better errno if get_direction is not available (diff)
downloadlinux-171948ea33e14dd1e49ba6439eabe822449ffd21.tar.xz
linux-171948ea33e14dd1e49ba6439eabe822449ffd21.zip
gpiolib: check if irqchip already has the irq hook replacements
Some drivers use a single irqchip for multiple gpiochips. As a result the irqchip hooks are overridden for the first gpiochip that was added, but for the other gpiochip instances this should not happen again, otherwise we would go into an infinite recursion. Check for this, but also log a message that the driver should be fixed since this is bad practice. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Tested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to '')
-rw-r--r--drivers/gpio/gpiolib.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 74f3af2d8ca0..940180b5704e 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1858,6 +1858,16 @@ static void gpiochip_set_irq_hooks(struct gpio_chip *gpiochip)
}
if (WARN_ON(gpiochip->irq.irq_enable))
return;
+ /* Check if the irqchip already has this hook... */
+ if (irqchip->irq_enable == gpiochip_irq_enable) {
+ /*
+ * ...and if so, give a gentle warning that this is bad
+ * practice.
+ */
+ chip_info(gpiochip,
+ "detected irqchip that is shared with multiple gpiochips: please fix the driver.\n");
+ return;
+ }
gpiochip->irq.irq_enable = irqchip->irq_enable;
gpiochip->irq.irq_disable = irqchip->irq_disable;
irqchip->irq_enable = gpiochip_irq_enable;