History

gpiolib: Introduce gpiod_set_config()

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.

Geert Uytterhoeven committed 6 years ago

Commit 8ced32f1 parent 06dd3f32 files · +30 −6Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/gpio/consumer.h+8−0
@@ -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
160int gpiod_set_config(struct gpio_desc *desc, unsigned long config);
160int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce);161int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce);
161int gpiod_set_transitory(struct gpio_desc *desc, bool transitory);162int gpiod_set_transitory(struct gpio_desc *desc, bool transitory);
162void gpiod_toggle_active_low(struct gpio_desc *desc);163void 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
477static 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
476static inline int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce)484static 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 */