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
157157 struct gpio_array *array_info,
158158 unsigned long *value_bitmap);
159159
160+int gpiod_set_config(struct gpio_desc *desc, unsigned long config);
160161 int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce);
161162 int gpiod_set_transitory(struct gpio_desc *desc, bool transitory);
162163 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
473474 return 0;
474475 }
475476
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+
476484 static inline int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce)
477485 {
478486 /* GPIO can never have been requested */