diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2017-01-11 07:37:07 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-01-19 03:57:20 -0500 |
commit | 739e6f5945d88dcee01590913f6886132a10c215 (patch) | |
tree | 5c53e38e08e39a10e827757c7057838e977e38fa | |
parent | 49def1853334396f948dcb4cedb9347abb318df5 (diff) |
gpio: provide lockdep keys for nested/unnested irqchips
The helper function for adding a GPIO chip compiles in a lockdep
key for debugging, the same key is needed for nested chips as
well.
The macro construction is unreadable, replace this with two
static inlines instead.
The _gpiochip_irqchip_add prefixed function is not helpful,
rename it with gpiochip_irqchip_add_key() that tell us what the
function is actually doing.
Fixes: d245b3f9bd36 ("gpio: simplify adding threaded interrupts")
Cc: Roger Quadros <rogerq@ti.com>
Reported-by: Clemens Gruber <clemens.gruber@pqgruber.com>
Reported-by: Roger Quadros <rogerq@ti.com>
Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
Tested-by: Clemens Gruber <clemens.gruber@pqgruber.com>
Tested-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpiolib.c | 18 | ||||
-rw-r--r-- | include/linux/gpio/driver.h | 70 |
2 files changed, 59 insertions, 29 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 86bf3b84ada5..a07ae9e37930 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -1723,7 +1723,7 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip) | |||
1723 | } | 1723 | } |
1724 | 1724 | ||
1725 | /** | 1725 | /** |
1726 | * _gpiochip_irqchip_add() - adds an irqchip to a gpiochip | 1726 | * gpiochip_irqchip_add_key() - adds an irqchip to a gpiochip |
1727 | * @gpiochip: the gpiochip to add the irqchip to | 1727 | * @gpiochip: the gpiochip to add the irqchip to |
1728 | * @irqchip: the irqchip to add to the gpiochip | 1728 | * @irqchip: the irqchip to add to the gpiochip |
1729 | * @first_irq: if not dynamically assigned, the base (first) IRQ to | 1729 | * @first_irq: if not dynamically assigned, the base (first) IRQ to |
@@ -1749,13 +1749,13 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip) | |||
1749 | * the pins on the gpiochip can generate a unique IRQ. Everything else | 1749 | * the pins on the gpiochip can generate a unique IRQ. Everything else |
1750 | * need to be open coded. | 1750 | * need to be open coded. |
1751 | */ | 1751 | */ |
1752 | int _gpiochip_irqchip_add(struct gpio_chip *gpiochip, | 1752 | int gpiochip_irqchip_add_key(struct gpio_chip *gpiochip, |
1753 | struct irq_chip *irqchip, | 1753 | struct irq_chip *irqchip, |
1754 | unsigned int first_irq, | 1754 | unsigned int first_irq, |
1755 | irq_flow_handler_t handler, | 1755 | irq_flow_handler_t handler, |
1756 | unsigned int type, | 1756 | unsigned int type, |
1757 | bool nested, | 1757 | bool nested, |
1758 | struct lock_class_key *lock_key) | 1758 | struct lock_class_key *lock_key) |
1759 | { | 1759 | { |
1760 | struct device_node *of_node; | 1760 | struct device_node *of_node; |
1761 | bool irq_base_set = false; | 1761 | bool irq_base_set = false; |
@@ -1840,7 +1840,7 @@ int _gpiochip_irqchip_add(struct gpio_chip *gpiochip, | |||
1840 | 1840 | ||
1841 | return 0; | 1841 | return 0; |
1842 | } | 1842 | } |
1843 | EXPORT_SYMBOL_GPL(_gpiochip_irqchip_add); | 1843 | EXPORT_SYMBOL_GPL(gpiochip_irqchip_add_key); |
1844 | 1844 | ||
1845 | #else /* CONFIG_GPIOLIB_IRQCHIP */ | 1845 | #else /* CONFIG_GPIOLIB_IRQCHIP */ |
1846 | 1846 | ||
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index c2748accea71..e973faba69dc 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h | |||
@@ -274,37 +274,67 @@ void gpiochip_set_nested_irqchip(struct gpio_chip *gpiochip, | |||
274 | struct irq_chip *irqchip, | 274 | struct irq_chip *irqchip, |
275 | int parent_irq); | 275 | int parent_irq); |
276 | 276 | ||
277 | int _gpiochip_irqchip_add(struct gpio_chip *gpiochip, | 277 | int gpiochip_irqchip_add_key(struct gpio_chip *gpiochip, |
278 | struct irq_chip *irqchip, | ||
279 | unsigned int first_irq, | ||
280 | irq_flow_handler_t handler, | ||
281 | unsigned int type, | ||
282 | bool nested, | ||
283 | struct lock_class_key *lock_key); | ||
284 | |||
285 | #ifdef CONFIG_LOCKDEP | ||
286 | |||
287 | /* | ||
288 | * Lockdep requires that each irqchip instance be created with a | ||
289 | * unique key so as to avoid unnecessary warnings. This upfront | ||
290 | * boilerplate static inlines provides such a key for each | ||
291 | * unique instance. | ||
292 | */ | ||
293 | static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip, | ||
294 | struct irq_chip *irqchip, | ||
295 | unsigned int first_irq, | ||
296 | irq_flow_handler_t handler, | ||
297 | unsigned int type) | ||
298 | { | ||
299 | static struct lock_class_key key; | ||
300 | |||
301 | return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq, | ||
302 | handler, type, false, &key); | ||
303 | } | ||
304 | |||
305 | static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip, | ||
278 | struct irq_chip *irqchip, | 306 | struct irq_chip *irqchip, |
279 | unsigned int first_irq, | 307 | unsigned int first_irq, |
280 | irq_flow_handler_t handler, | 308 | irq_flow_handler_t handler, |
281 | unsigned int type, | 309 | unsigned int type) |
282 | bool nested, | 310 | { |
283 | struct lock_class_key *lock_key); | 311 | |
312 | static struct lock_class_key key; | ||
313 | |||
314 | return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq, | ||
315 | handler, type, true, &key); | ||
316 | } | ||
317 | #else | ||
318 | static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip, | ||
319 | struct irq_chip *irqchip, | ||
320 | unsigned int first_irq, | ||
321 | irq_flow_handler_t handler, | ||
322 | unsigned int type) | ||
323 | { | ||
324 | return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq, | ||
325 | handler, type, false, NULL); | ||
326 | } | ||
284 | 327 | ||
285 | /* FIXME: I assume threaded IRQchips do not have the lockdep problem */ | ||
286 | static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip, | 328 | static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip, |
287 | struct irq_chip *irqchip, | 329 | struct irq_chip *irqchip, |
288 | unsigned int first_irq, | 330 | unsigned int first_irq, |
289 | irq_flow_handler_t handler, | 331 | irq_flow_handler_t handler, |
290 | unsigned int type) | 332 | unsigned int type) |
291 | { | 333 | { |
292 | return _gpiochip_irqchip_add(gpiochip, irqchip, first_irq, | 334 | return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq, |
293 | handler, type, true, NULL); | 335 | handler, type, true, NULL); |
294 | } | 336 | } |
295 | 337 | #endif /* CONFIG_LOCKDEP */ | |
296 | #ifdef CONFIG_LOCKDEP | ||
297 | #define gpiochip_irqchip_add(...) \ | ||
298 | ( \ | ||
299 | ({ \ | ||
300 | static struct lock_class_key _key; \ | ||
301 | _gpiochip_irqchip_add(__VA_ARGS__, false, &_key); \ | ||
302 | }) \ | ||
303 | ) | ||
304 | #else | ||
305 | #define gpiochip_irqchip_add(...) \ | ||
306 | _gpiochip_irqchip_add(__VA_ARGS__, false, NULL) | ||
307 | #endif | ||
308 | 338 | ||
309 | #endif /* CONFIG_GPIOLIB_IRQCHIP */ | 339 | #endif /* CONFIG_GPIOLIB_IRQCHIP */ |
310 | 340 | ||