gpio: don't use same lockdep class for all devm_gpiochip_add_data users
Commit959bc7b22b
("gpio: Automatically add lockdep keys") documents in its commits message its intention to "create a unique class key for each driver". It does so by having gpiochip_add_data add in-place the definition of two static lockdep classes for LOCKDEP use. That way, every caller of the macro adds their gpiochip with unique lockdep classes. There are many indirect callers of gpiochip_add_data, however, via use of devm_gpiochip_add_data. devm_gpiochip_add_data has external linkage and all its users will share the same lockdep classes, which probably is not intended. Fix this by replicating the gpio_chip_add_data statics-in-macro for the devm_ version as well. Fixes:959bc7b22b
("gpio: Automatically add lockdep keys") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Link: https://lore.kernel.org/r/20200731123835.8003-1-a.fatoum@pengutronix.de Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:

committed by
Linus Walleij

parent
bb58a47a12
commit
5f402bb175
@@ -525,8 +525,16 @@ extern int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
|
||||
gpiochip_add_data_with_key(gc, data, &lock_key, \
|
||||
&request_key); \
|
||||
})
|
||||
#define devm_gpiochip_add_data(dev, gc, data) ({ \
|
||||
static struct lock_class_key lock_key; \
|
||||
static struct lock_class_key request_key; \
|
||||
devm_gpiochip_add_data_with_key(dev, gc, data, &lock_key, \
|
||||
&request_key); \
|
||||
})
|
||||
#else
|
||||
#define gpiochip_add_data(gc, data) gpiochip_add_data_with_key(gc, data, NULL, NULL)
|
||||
#define devm_gpiochip_add_data(dev, gc, data) \
|
||||
devm_gpiochip_add_data_with_key(dev, gc, data, NULL, NULL)
|
||||
#endif /* CONFIG_LOCKDEP */
|
||||
|
||||
static inline int gpiochip_add(struct gpio_chip *gc)
|
||||
@@ -534,8 +542,9 @@ static inline int gpiochip_add(struct gpio_chip *gc)
|
||||
return gpiochip_add_data(gc, NULL);
|
||||
}
|
||||
extern void gpiochip_remove(struct gpio_chip *gc);
|
||||
extern int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *gc,
|
||||
void *data);
|
||||
extern int devm_gpiochip_add_data_with_key(struct device *dev, struct gpio_chip *gc, void *data,
|
||||
struct lock_class_key *lock_key,
|
||||
struct lock_class_key *request_key);
|
||||
|
||||
extern struct gpio_chip *gpiochip_find(void *data,
|
||||
int (*match)(struct gpio_chip *gc, void *data));
|
||||
|
Reference in New Issue
Block a user