Skip to content

Commit 91931af

Browse files
dlechBartosz Golaszewski
authored andcommitted
gpiolib: add gpiod_multi_set_value_cansleep()
Add a new gpiod_multi_set_value_cansleep() helper function with fewer parameters than gpiod_set_array_value_cansleep(). Calling gpiod_set_array_value_cansleep() can get quite verbose. In many cases, the first arguments all come from the same struct gpio_descs, so having a separate function where we can just pass that cuts down on the boilerplate. Signed-off-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/20250210-gpio-set-array-helper-v3-1-d6a673674da8@baylibre.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent 2014c95 commit 91931af

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/linux/gpio/consumer.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define __LINUX_GPIO_CONSUMER_H
44

55
#include <linux/bits.h>
6+
#include <linux/err.h>
67
#include <linux/types.h>
78

89
struct acpi_device;
@@ -655,4 +656,14 @@ static inline void gpiod_unexport(struct gpio_desc *desc)
655656

656657
#endif /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */
657658

659+
static inline int gpiod_multi_set_value_cansleep(struct gpio_descs *descs,
660+
unsigned long *value_bitmap)
661+
{
662+
if (IS_ERR_OR_NULL(descs))
663+
return PTR_ERR_OR_ZERO(descs);
664+
665+
return gpiod_set_array_value_cansleep(descs->ndescs, descs->desc,
666+
descs->info, value_bitmap);
667+
}
668+
658669
#endif

0 commit comments

Comments
 (0)