mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-22 23:13:01 +02:00
gpio: regmap: 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> Reviewed-by: Michael Walle <mwalle@kernel.org> Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Link: https://lore.kernel.org/r/20250220-gpio-set-retval-v2-7-bc4cfd38dae3@linaro.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
fe69bedc77
commit
a458d2309c
|
@ -83,33 +83,43 @@ static int gpio_regmap_get(struct gpio_chip *chip, unsigned int offset)
|
|||
return !!(val & mask);
|
||||
}
|
||||
|
||||
static void gpio_regmap_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int val)
|
||||
static int gpio_regmap_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int val)
|
||||
{
|
||||
struct gpio_regmap *gpio = gpiochip_get_data(chip);
|
||||
unsigned int base = gpio_regmap_addr(gpio->reg_set_base);
|
||||
unsigned int reg, mask;
|
||||
int ret;
|
||||
|
||||
ret = gpio->reg_mask_xlate(gpio, base, offset, ®, &mask);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
gpio->reg_mask_xlate(gpio, base, offset, ®, &mask);
|
||||
if (val)
|
||||
regmap_update_bits(gpio->regmap, reg, mask, mask);
|
||||
ret = regmap_update_bits(gpio->regmap, reg, mask, mask);
|
||||
else
|
||||
regmap_update_bits(gpio->regmap, reg, mask, 0);
|
||||
ret = regmap_update_bits(gpio->regmap, reg, mask, 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void gpio_regmap_set_with_clear(struct gpio_chip *chip,
|
||||
unsigned int offset, int val)
|
||||
static int gpio_regmap_set_with_clear(struct gpio_chip *chip,
|
||||
unsigned int offset, int val)
|
||||
{
|
||||
struct gpio_regmap *gpio = gpiochip_get_data(chip);
|
||||
unsigned int base, reg, mask;
|
||||
int ret;
|
||||
|
||||
if (val)
|
||||
base = gpio_regmap_addr(gpio->reg_set_base);
|
||||
else
|
||||
base = gpio_regmap_addr(gpio->reg_clr_base);
|
||||
|
||||
gpio->reg_mask_xlate(gpio, base, offset, ®, &mask);
|
||||
regmap_write(gpio->regmap, reg, mask);
|
||||
ret = gpio->reg_mask_xlate(gpio, base, offset, ®, &mask);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return regmap_write(gpio->regmap, reg, mask);
|
||||
}
|
||||
|
||||
static int gpio_regmap_get_direction(struct gpio_chip *chip,
|
||||
|
@ -250,9 +260,9 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
|
|||
chip->free = gpiochip_generic_free;
|
||||
chip->get = gpio_regmap_get;
|
||||
if (gpio->reg_set_base && gpio->reg_clr_base)
|
||||
chip->set = gpio_regmap_set_with_clear;
|
||||
chip->set_rv = gpio_regmap_set_with_clear;
|
||||
else if (gpio->reg_set_base)
|
||||
chip->set = gpio_regmap_set;
|
||||
chip->set_rv = gpio_regmap_set;
|
||||
|
||||
chip->get_direction = gpio_regmap_get_direction;
|
||||
if (gpio->reg_dir_in_base || gpio->reg_dir_out_base) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user