Commit eb2e9c30 authored by David Lechner's avatar David Lechner Committed by Bartosz Golaszewski
Browse files

gpio: max3191x: use gpiod_multi_set_value_cansleep



Reduce verbosity by using gpiod_multi_set_value_cansleep() instead of
gpiod_set_array_value_cansleep().

Also add max3191x_ namespace prefix to the driver's helper function
since we are changing the function signature anyway.

Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarDavid Lechner <dlechner@baylibre.com>
Reviewed-by: default avatarAndy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20250210-gpio-set-array-helper-v3-6-d6a673674da8@baylibre.com


Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent e6aaeffe
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -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 max3191x_gpiod_multi_set_single_value(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);
		max3191x_gpiod_multi_set_single_value(max3191x->modesel_pins,
						      max3191x->mode);

	max3191x->ignore_uv = device_property_read_bool(dev,
						  "maxim,ignore-undervoltage");