Commit 2e6b7f5f authored by Bartosz Golaszewski's avatar Bartosz Golaszewski
Browse files

gpio: madera: 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.

Reviewed-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20250506-gpiochip-set-rv-gpio-part3-v1-5-0fbdea5a9667@linaro.org


Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent 1a7b6b53
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -87,23 +87,17 @@ static int madera_gpio_direction_out(struct gpio_chip *chip,
				  MADERA_GP1_LVL_MASK, reg_val);
}

static void madera_gpio_set(struct gpio_chip *chip, unsigned int offset,
static int madera_gpio_set(struct gpio_chip *chip, unsigned int offset,
			   int value)
{
	struct madera_gpio *madera_gpio = gpiochip_get_data(chip);
	struct madera *madera = madera_gpio->madera;
	unsigned int reg_offset = 2 * offset;
	unsigned int reg_val = value ? MADERA_GP1_LVL : 0;
	int ret;

	ret = regmap_update_bits(madera->regmap,
	return regmap_update_bits(madera->regmap,
				  MADERA_GPIO1_CTRL_1 + reg_offset,
				  MADERA_GP1_LVL_MASK, reg_val);

	/* set() doesn't return an error so log a warning */
	if (ret)
		dev_warn(madera->dev, "Failed to write to 0x%x (%d)\n",
			 MADERA_GPIO1_CTRL_1 + reg_offset, ret);
}

static const struct gpio_chip madera_gpio_chip = {
@@ -115,7 +109,7 @@ static const struct gpio_chip madera_gpio_chip = {
	.direction_input	= madera_gpio_direction_in,
	.get			= madera_gpio_get,
	.direction_output	= madera_gpio_direction_out,
	.set			= madera_gpio_set,
	.set_rv			= madera_gpio_set,
	.set_config		= gpiochip_generic_config,
	.can_sleep		= true,
};