Commit 978d23c1 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski
Browse files

gpio: lp87565: use new GPIO line value setter callbacks

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Link: https://lore.kernel.org/r/20250506-gpiochip-set-rv-gpio-part3-v1-2-0fbdea5a9667@linaro.org


Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent 30d15b89
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -30,12 +30,12 @@ static int lp87565_gpio_get(struct gpio_chip *chip, unsigned int offset)
	return !!(val & BIT(offset));
}

static void lp87565_gpio_set(struct gpio_chip *chip, unsigned int offset,
static int lp87565_gpio_set(struct gpio_chip *chip, unsigned int offset,
			    int value)
{
	struct lp87565_gpio *gpio = gpiochip_get_data(chip);

	regmap_update_bits(gpio->map, LP87565_REG_GPIO_OUT,
	return regmap_update_bits(gpio->map, LP87565_REG_GPIO_OUT,
				  BIT(offset), value ? BIT(offset) : 0);
}

@@ -69,8 +69,11 @@ static int lp87565_gpio_direction_output(struct gpio_chip *chip,
					 unsigned int offset, int value)
{
	struct lp87565_gpio *gpio = gpiochip_get_data(chip);
	int ret;

	lp87565_gpio_set(chip, offset, value);
	ret = lp87565_gpio_set(chip, offset, value);
	if (ret)
		return ret;

	return regmap_update_bits(gpio->map,
				  LP87565_REG_GPIO_CONFIG,
@@ -136,7 +139,7 @@ static const struct gpio_chip template_chip = {
	.direction_input	= lp87565_gpio_direction_input,
	.direction_output	= lp87565_gpio_direction_output,
	.get			= lp87565_gpio_get,
	.set			= lp87565_gpio_set,
	.set_rv			= lp87565_gpio_set,
	.set_config		= lp87565_gpio_set_config,
	.base			= -1,
	.ngpio			= 3,