[PATCH 01/13] gpiolib: add gpiods_set_array_value_cansleep()

David Lechner posted 13 patches 1 year ago
[PATCH 01/13] gpiolib: add gpiods_set_array_value_cansleep()
Posted by David Lechner 1 year ago
Add a new gpiods_set_array_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>
---
 include/linux/gpio/consumer.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index db2dfbae8edbd12059826183b1c0f73c7a58ff40..1c9bb3cb1ee80fe52aabf5bd24b1d128eff2bc99 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -655,4 +655,11 @@ static inline void gpiod_unexport(struct gpio_desc *desc)
 
 #endif /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */
 
+static inline int gpiods_set_array_value_cansleep(struct gpio_descs *descs,
+						  unsigned long *value_bitmap)
+{
+	return gpiod_set_array_value_cansleep(descs->ndescs, descs->desc,
+					      descs->info, value_bitmap);
+}
+
 #endif

-- 
2.43.0
Re: [PATCH 01/13] gpiolib: add gpiods_set_array_value_cansleep()
Posted by Andy Shevchenko 1 year ago
On Fri, Jan 31, 2025 at 10:24 PM David Lechner <dlechner@baylibre.com> wrote:
>
> Add a new gpiods_set_array_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.

...

> +static inline int gpiods_set_array_value_cansleep(struct gpio_descs *descs,
> +                                                 unsigned long *value_bitmap)

My proposal was to make this gpiod_set_many_value_cansleep(), but I'm
not pretending it's the best choice.

> +{
> +       return gpiod_set_array_value_cansleep(descs->ndescs, descs->desc,
> +                                             descs->info, value_bitmap);
> +}

I don't remember seeing the _bitmap suffix in other GPIO APIs, perhaps
just drop it?

-- 
With Best Regards,
Andy Shevchenko