Message ID | 20250206-gpio-set-array-helper-v2-5-1c5f048f79c3@baylibre.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | gpiolib: add gpiod_multi_set_value_cansleep | expand |
On Fri, Feb 7, 2025 at 12:48 AM David Lechner <dlechner@baylibre.com> wrote: > > Reduce verbosity by using gpiod_multi_set_value_cansleep() instead of > gpiod_set_array_value_cansleep(). It seems you missed my comment. > +static void gpiod_set_array_single_value_cansleep(struct gpio_descs *descs, > int value) This is not good namespacing. Can we change this while at it? max3191x_... (I would go with max3191x_set_modesel_pins() to make it shorter. I have no clue why the function repeats so much from gpiod API naming. Is there anything else which is named in a similar way? Perhaps fix it by a separate patch?)
On 2/7/25 4:34 AM, Andy Shevchenko wrote: > On Fri, Feb 7, 2025 at 12:48 AM David Lechner <dlechner@baylibre.com> wrote: >> >> Reduce verbosity by using gpiod_multi_set_value_cansleep() instead of >> gpiod_set_array_value_cansleep(). > > It seems you missed my comment. Yes, I must have been sleeping on the job. :-/ > >> +static void gpiod_set_array_single_value_cansleep(struct gpio_descs *descs, >> int value) > > This is not good namespacing. Can we change this while at it? sure > > max3191x_... > > (I would go with max3191x_set_modesel_pins() to make it shorter. I > have no clue why the function repeats so much from gpiod API naming. > Is there anything else which is named in a similar way? Perhaps fix it > by a separate patch?) >
diff --git a/drivers/gpio/gpio-max3191x.c b/drivers/gpio/gpio-max3191x.c index bbacc714632b70e672a3d8494636fbc40dfea8ec..36ca07be3e1811fd3f0b27f41bfd307de50ec5b4 100644 --- a/drivers/gpio/gpio-max3191x.c +++ b/drivers/gpio/gpio-max3191x.c @@ -309,23 +309,21 @@ static int max3191x_set_config(struct gpio_chip *gpio, unsigned int offset, return 0; } -static void gpiod_set_array_single_value_cansleep(unsigned int ndescs, - struct gpio_desc **desc, - struct gpio_array *info, +static void gpiod_set_array_single_value_cansleep(struct gpio_descs *descs, int value) { unsigned long *values; - values = bitmap_alloc(ndescs, GFP_KERNEL); + values = bitmap_alloc(descs->ndescs, GFP_KERNEL); if (!values) return; if (value) - bitmap_fill(values, ndescs); + bitmap_fill(values, descs->ndescs); else - bitmap_zero(values, ndescs); + bitmap_zero(values, descs->ndescs); - gpiod_set_array_value_cansleep(ndescs, desc, info, values); + gpiod_multi_set_value_cansleep(descs, values); bitmap_free(values); } @@ -396,10 +394,8 @@ static int max3191x_probe(struct spi_device *spi) max3191x->mode = device_property_read_bool(dev, "maxim,modesel-8bit") ? STATUS_BYTE_DISABLED : STATUS_BYTE_ENABLED; if (max3191x->modesel_pins) - gpiod_set_array_single_value_cansleep( - max3191x->modesel_pins->ndescs, - max3191x->modesel_pins->desc, - max3191x->modesel_pins->info, max3191x->mode); + gpiod_set_array_single_value_cansleep(max3191x->modesel_pins, + max3191x->mode); max3191x->ignore_uv = device_property_read_bool(dev, "maxim,ignore-undervoltage");