mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 15:03:52 +08:00
gpio: pca953x: use value returning setters
struct gpio_chip now has additional variants of the set(_multiple) driver callbacks that return an integer to indicate success or failure. Convert the driver to using them. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Link: https://lore.kernel.org/r/20250220-gpio-set-retval-v2-8-bc4cfd38dae3@linaro.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
@@ -570,7 +570,8 @@ static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off)
|
||||
return !!(reg_val & bit);
|
||||
}
|
||||
|
||||
static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val)
|
||||
static int pca953x_gpio_set_value(struct gpio_chip *gc, unsigned int off,
|
||||
int val)
|
||||
{
|
||||
struct pca953x_chip *chip = gpiochip_get_data(gc);
|
||||
u8 outreg = chip->recalc_addr(chip, chip->regs->output, off);
|
||||
@@ -578,7 +579,7 @@ static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val)
|
||||
|
||||
guard(mutex)(&chip->i2c_lock);
|
||||
|
||||
regmap_write_bits(chip->regmap, outreg, bit, val ? bit : 0);
|
||||
return regmap_write_bits(chip->regmap, outreg, bit, val ? bit : 0);
|
||||
}
|
||||
|
||||
static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
|
||||
@@ -616,8 +617,8 @@ static int pca953x_gpio_get_multiple(struct gpio_chip *gc,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
|
||||
unsigned long *mask, unsigned long *bits)
|
||||
static int pca953x_gpio_set_multiple(struct gpio_chip *gc,
|
||||
unsigned long *mask, unsigned long *bits)
|
||||
{
|
||||
struct pca953x_chip *chip = gpiochip_get_data(gc);
|
||||
DECLARE_BITMAP(reg_val, MAX_LINE);
|
||||
@@ -627,11 +628,11 @@ static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
|
||||
|
||||
ret = pca953x_read_regs(chip, chip->regs->output, reg_val);
|
||||
if (ret)
|
||||
return;
|
||||
return ret;
|
||||
|
||||
bitmap_replace(reg_val, reg_val, bits, mask, gc->ngpio);
|
||||
|
||||
pca953x_write_regs(chip, chip->regs->output, reg_val);
|
||||
return pca953x_write_regs(chip, chip->regs->output, reg_val);
|
||||
}
|
||||
|
||||
static int pca953x_gpio_set_pull_up_down(struct pca953x_chip *chip,
|
||||
@@ -693,10 +694,10 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios)
|
||||
gc->direction_input = pca953x_gpio_direction_input;
|
||||
gc->direction_output = pca953x_gpio_direction_output;
|
||||
gc->get = pca953x_gpio_get_value;
|
||||
gc->set = pca953x_gpio_set_value;
|
||||
gc->set_rv = pca953x_gpio_set_value;
|
||||
gc->get_direction = pca953x_gpio_get_direction;
|
||||
gc->get_multiple = pca953x_gpio_get_multiple;
|
||||
gc->set_multiple = pca953x_gpio_set_multiple;
|
||||
gc->set_multiple_rv = pca953x_gpio_set_multiple;
|
||||
gc->set_config = pca953x_gpio_set_config;
|
||||
gc->can_sleep = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user