diff options
Diffstat (limited to 'include/linux/gpio/driver.h')
| -rw-r--r-- | include/linux/gpio/driver.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index a77d4ada060c..8dd282c5167a 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h | |||
| @@ -321,7 +321,41 @@ extern const char *gpiochip_is_requested(struct gpio_chip *chip, | |||
| 321 | unsigned offset); | 321 | unsigned offset); |
| 322 | 322 | ||
| 323 | /* add/remove chips */ | 323 | /* add/remove chips */ |
| 324 | extern int gpiochip_add_data(struct gpio_chip *chip, void *data); | 324 | extern int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, |
| 325 | struct lock_class_key *lock_key); | ||
| 326 | |||
| 327 | /** | ||
| 328 | * gpiochip_add_data() - register a gpio_chip | ||
| 329 | * @chip: the chip to register, with chip->base initialized | ||
| 330 | * @data: driver-private data associated with this chip | ||
| 331 | * | ||
| 332 | * Context: potentially before irqs will work | ||
| 333 | * | ||
| 334 | * When gpiochip_add_data() is called very early during boot, so that GPIOs | ||
| 335 | * can be freely used, the chip->parent device must be registered before | ||
| 336 | * the gpio framework's arch_initcall(). Otherwise sysfs initialization | ||
| 337 | * for GPIOs will fail rudely. | ||
| 338 | * | ||
| 339 | * gpiochip_add_data() must only be called after gpiolib initialization, | ||
| 340 | * ie after core_initcall(). | ||
| 341 | * | ||
| 342 | * If chip->base is negative, this requests dynamic assignment of | ||
| 343 | * a range of valid GPIOs. | ||
| 344 | * | ||
| 345 | * Returns: | ||
| 346 | * A negative errno if the chip can't be registered, such as because the | ||
| 347 | * chip->base is invalid or already associated with a different chip. | ||
| 348 | * Otherwise it returns zero as a success code. | ||
| 349 | */ | ||
| 350 | #ifdef CONFIG_LOCKDEP | ||
| 351 | #define gpiochip_add_data(chip, data) ({ \ | ||
| 352 | static struct lock_class_key key; \ | ||
| 353 | gpiochip_add_data_with_key(chip, data, &key); \ | ||
| 354 | }) | ||
| 355 | #else | ||
| 356 | #define gpiochip_add_data(chip, data) gpiochip_add_data_with_key(chip, data, NULL) | ||
| 357 | #endif | ||
| 358 | |||
| 325 | static inline int gpiochip_add(struct gpio_chip *chip) | 359 | static inline int gpiochip_add(struct gpio_chip *chip) |
| 326 | { | 360 | { |
| 327 | return gpiochip_add_data(chip, NULL); | 361 | return gpiochip_add_data(chip, NULL); |
