Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpiolib: provide gpiod_remove_hogs()

Currently all users of gpiod_add_hogs() call it only once at system
init so there never was any need for a mechanism allowing to remove
them. Now the upcoming gpio-sim will need to tear down chips with hogged
lines so provide a function that allows to remove hogs.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>

+13
+11
drivers/gpio/gpiolib.c
··· 3557 3557 } 3558 3558 EXPORT_SYMBOL_GPL(gpiod_add_hogs); 3559 3559 3560 + void gpiod_remove_hogs(struct gpiod_hog *hogs) 3561 + { 3562 + struct gpiod_hog *hog; 3563 + 3564 + mutex_lock(&gpio_machine_hogs_mutex); 3565 + for (hog = &hogs[0]; hog->chip_label; hog++) 3566 + list_del(&hog->list); 3567 + mutex_unlock(&gpio_machine_hogs_mutex); 3568 + } 3569 + EXPORT_SYMBOL_GPL(gpiod_remove_hogs); 3570 + 3560 3571 static struct gpiod_lookup_table *gpiod_find_lookup_table(struct device *dev) 3561 3572 { 3562 3573 const char *dev_id = dev ? dev_name(dev) : NULL;
+2
include/linux/gpio/machine.h
··· 100 100 void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n); 101 101 void gpiod_remove_lookup_table(struct gpiod_lookup_table *table); 102 102 void gpiod_add_hogs(struct gpiod_hog *hogs); 103 + void gpiod_remove_hogs(struct gpiod_hog *hogs); 103 104 #else /* ! CONFIG_GPIOLIB */ 104 105 static inline 105 106 void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {} ··· 109 108 static inline 110 109 void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {} 111 110 static inline void gpiod_add_hogs(struct gpiod_hog *hogs) {} 111 + static inline void gpiod_remove_hogs(struct gpiod_hog *hogs) {} 112 112 #endif /* CONFIG_GPIOLIB */ 113 113 114 114 #endif /* __LINUX_GPIO_MACHINE_H */