[PATCH] gpiolib: irqchip: fix lockdep warning from gpiochip_irqchip_add_nested

From: Grygorii Strashko
Date: Tue Jan 10 2017 - 14:41:39 EST


Each GPIO IRQ chip should register separate lockdep class otherwise lockdep
will complain every time when GPIO chips organized in chain whare all of
them are IRQ controllers and one GPIO pin is used as interrupt input from
another. This issue was originally fixed by commit a0a8bcf4670c ("gpiolib:
irqchip: use different lockdep class for each gpio irqchip") and then
re-introduced for GPIO chips which are using nested IRQ handlers by commit
d245b3f9bd3 ("gpio: simplify adding threaded interrupts").

Hence, fix it the same way as it was done for gpiochip_irqchip_add() by
wrapping gpiochip_irqchip_add_nested calls into macros.

Fixes: d245b3f9bd3 ("gpio: simplify adding threaded interrupts")
Signed-off-by: Grygorii Strashko <grygorii.strashko@xxxxxx>
---
include/linux/gpio/driver.h | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index c2748ac..eae438b 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -283,15 +283,20 @@ int _gpiochip_irqchip_add(struct gpio_chip *gpiochip,
struct lock_class_key *lock_key);

/* FIXME: I assume threaded IRQchips do not have the lockdep problem */
-static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip,
- struct irq_chip *irqchip,
- unsigned int first_irq,
- irq_flow_handler_t handler,
- unsigned int type)
-{
- return _gpiochip_irqchip_add(gpiochip, irqchip, first_irq,
- handler, type, true, NULL);
-}
+#ifdef CONFIG_LOCKDEP
+#define gpiochip_irqchip_add_nested(gpiochip, irqchip, \
+ first_irq, handler, type) \
+( \
+ ({ \
+ static struct lock_class_key _key; \
+ _gpiochip_irqchip_add(gpiochip, irqchip, first_irq, \
+ handler, type, true, &_key); \
+ }) \
+)
+#else
+#define gpiochip_irqchip_add_nested(...) \
+ _gpiochip_irqchip_add(__VA_ARGS__, true, NULL)
+#endif

#ifdef CONFIG_LOCKDEP
#define gpiochip_irqchip_add(...) \
--
2.10.1.dirty


--
regards,
-grygorii