The GPIO Aggregator will need a method to forward a .set_config() call to its parent gpiochip. This requires obtaining the gpio_chip and offset for a given gpio_desc. While gpiod_to_chip() is public, gpio_chip_hwgpio() is not, so there is currently no method to obtain the needed GPIO offset parameter. Hence introduce a public gpiod_set_config() helper, which invokes the .set_config() callback through a gpio_desc pointer, like is done for most other gpio_chip callbacks. Rewrite the existing gpiod_set_debounce() helper as a wrapper around gpiod_set_config(), to avoid duplication.
Showing the changes to include/linux (1 of 2 files). Show all
Unified · Split
| @@ -157,6 +157,7 @@ int gpiod_set_raw_array_value_cansleep(unsigned int array_size, · 156 unmodified lines | |||
| 157 | struct gpio_array *array_info, | 157 | struct gpio_array *array_info, |
| 158 | unsigned long *value_bitmap); | 158 | unsigned long *value_bitmap); |
| 159 | 159 | ||
| 160 | int gpiod_set_config(struct gpio_desc *desc, unsigned long config); | ||
| 160 | int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce); | 161 | int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce); |
| 161 | int gpiod_set_transitory(struct gpio_desc *desc, bool transitory); | 162 | int gpiod_set_transitory(struct gpio_desc *desc, bool transitory); |
| 162 | void gpiod_toggle_active_low(struct gpio_desc *desc); | 163 | void gpiod_toggle_active_low(struct gpio_desc *desc); |
| @@ -473,6 +474,13 @@ static inline int gpiod_set_raw_array_value_cansleep(unsigned int array_size, · 310 unmodified lines | |||
| 473 | return 0; | 474 | return 0; |
| 474 | } | 475 | } |
| 475 | 476 | ||
| 477 | static inline int gpiod_set_config(struct gpio_desc *desc, unsigned long config) | ||
| 478 | { | ||
| 479 | /* GPIO can never have been requested */ | ||
| 480 | WARN_ON(desc); | ||
| 481 | return -ENOSYS; | ||
| 482 | } | ||
| 483 | |||
| 476 | static inline int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) | 484 | static inline int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) |
| 477 | { | 485 | { |
| 478 | /* GPIO can never have been requested */ | 486 | /* GPIO can never have been requested */ |