gpio: tpic2810: 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/20250702-gpiochip-set-rv-gpio-round3-v1-7-0d23be74f71d@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
Bartosz Golaszewski
2025-07-02 11:14:08 +02:00
parent 00c337cc68
commit 4ffdd9d8a3

View File

@@ -25,7 +25,7 @@ struct tpic2810 {
struct mutex lock;
};
static void tpic2810_set(struct gpio_chip *chip, unsigned offset, int value);
static int tpic2810_set(struct gpio_chip *chip, unsigned int offset, int value);
static int tpic2810_get_direction(struct gpio_chip *chip,
unsigned offset)
@@ -38,8 +38,7 @@ static int tpic2810_direction_output(struct gpio_chip *chip,
unsigned offset, int value)
{
/* This device always output */
tpic2810_set(chip, offset, value);
return 0;
return tpic2810_set(chip, offset, value);
}
static void tpic2810_set_mask_bits(struct gpio_chip *chip, u8 mask, u8 bits)
@@ -61,15 +60,19 @@ static void tpic2810_set_mask_bits(struct gpio_chip *chip, u8 mask, u8 bits)
mutex_unlock(&gpio->lock);
}
static void tpic2810_set(struct gpio_chip *chip, unsigned offset, int value)
static int tpic2810_set(struct gpio_chip *chip, unsigned int offset, int value)
{
tpic2810_set_mask_bits(chip, BIT(offset), value ? BIT(offset) : 0);
return 0;
}
static void tpic2810_set_multiple(struct gpio_chip *chip, unsigned long *mask,
unsigned long *bits)
static int tpic2810_set_multiple(struct gpio_chip *chip, unsigned long *mask,
unsigned long *bits)
{
tpic2810_set_mask_bits(chip, *mask, *bits);
return 0;
}
static const struct gpio_chip template_chip = {
@@ -77,8 +80,8 @@ static const struct gpio_chip template_chip = {
.owner = THIS_MODULE,
.get_direction = tpic2810_get_direction,
.direction_output = tpic2810_direction_output,
.set = tpic2810_set,
.set_multiple = tpic2810_set_multiple,
.set_rv = tpic2810_set,
.set_multiple_rv = tpic2810_set_multiple,
.base = -1,
.ngpio = 8,
.can_sleep = true,