Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+9 -8
+9 -8
drivers/gpio/gpio-pca953x.c
··· 570 570 return !!(reg_val & bit); 571 571 } 572 572 573 - static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val) 573 + static int pca953x_gpio_set_value(struct gpio_chip *gc, unsigned int off, 574 + int val) 574 575 { 575 576 struct pca953x_chip *chip = gpiochip_get_data(gc); 576 577 u8 outreg = chip->recalc_addr(chip, chip->regs->output, off); ··· 579 578 580 579 guard(mutex)(&chip->i2c_lock); 581 580 582 - regmap_write_bits(chip->regmap, outreg, bit, val ? bit : 0); 581 + return regmap_write_bits(chip->regmap, outreg, bit, val ? bit : 0); 583 582 } 584 583 585 584 static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off) ··· 617 616 return 0; 618 617 } 619 618 620 - static void pca953x_gpio_set_multiple(struct gpio_chip *gc, 621 - unsigned long *mask, unsigned long *bits) 619 + static int pca953x_gpio_set_multiple(struct gpio_chip *gc, 620 + unsigned long *mask, unsigned long *bits) 622 621 { 623 622 struct pca953x_chip *chip = gpiochip_get_data(gc); 624 623 DECLARE_BITMAP(reg_val, MAX_LINE); ··· 628 627 629 628 ret = pca953x_read_regs(chip, chip->regs->output, reg_val); 630 629 if (ret) 631 - return; 630 + return ret; 632 631 633 632 bitmap_replace(reg_val, reg_val, bits, mask, gc->ngpio); 634 633 635 - pca953x_write_regs(chip, chip->regs->output, reg_val); 634 + return pca953x_write_regs(chip, chip->regs->output, reg_val); 636 635 } 637 636 638 637 static int pca953x_gpio_set_pull_up_down(struct pca953x_chip *chip, ··· 694 693 gc->direction_input = pca953x_gpio_direction_input; 695 694 gc->direction_output = pca953x_gpio_direction_output; 696 695 gc->get = pca953x_gpio_get_value; 697 - gc->set = pca953x_gpio_set_value; 696 + gc->set_rv = pca953x_gpio_set_value; 698 697 gc->get_direction = pca953x_gpio_get_direction; 699 698 gc->get_multiple = pca953x_gpio_get_multiple; 700 - gc->set_multiple = pca953x_gpio_set_multiple; 699 + gc->set_multiple_rv = pca953x_gpio_set_multiple; 701 700 gc->set_config = pca953x_gpio_set_config; 702 701 gc->can_sleep = true; 703 702