mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 09:09:55 -04:00
iio: addac: ad74413r: 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. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://patch.msgid.link/20250409-gpiochip-set-rv-iio-v2-6-4b36428f39cb@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
committed by
Jonathan Cameron
parent
3bb36fe058
commit
b8b3ea6429
@@ -276,8 +276,8 @@ static int ad74413r_set_comp_drive_strength(struct ad74413r_state *st,
|
||||
}
|
||||
|
||||
|
||||
static void ad74413r_gpio_set(struct gpio_chip *chip,
|
||||
unsigned int offset, int val)
|
||||
static int ad74413r_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int val)
|
||||
{
|
||||
struct ad74413r_state *st = gpiochip_get_data(chip);
|
||||
unsigned int real_offset = st->gpo_gpio_offsets[offset];
|
||||
@@ -286,16 +286,16 @@ static void ad74413r_gpio_set(struct gpio_chip *chip,
|
||||
ret = ad74413r_set_gpo_config(st, real_offset,
|
||||
AD74413R_GPO_CONFIG_LOGIC);
|
||||
if (ret)
|
||||
return;
|
||||
return ret;
|
||||
|
||||
regmap_update_bits(st->regmap, AD74413R_REG_GPO_CONFIG_X(real_offset),
|
||||
AD74413R_GPO_CONFIG_DATA_MASK,
|
||||
val ? AD74413R_GPO_CONFIG_DATA_MASK : 0);
|
||||
return regmap_update_bits(st->regmap,
|
||||
AD74413R_REG_GPO_CONFIG_X(real_offset),
|
||||
AD74413R_GPO_CONFIG_DATA_MASK,
|
||||
val ? AD74413R_GPO_CONFIG_DATA_MASK : 0);
|
||||
}
|
||||
|
||||
static void ad74413r_gpio_set_multiple(struct gpio_chip *chip,
|
||||
unsigned long *mask,
|
||||
unsigned long *bits)
|
||||
static int ad74413r_gpio_set_multiple(struct gpio_chip *chip,
|
||||
unsigned long *mask, unsigned long *bits)
|
||||
{
|
||||
struct ad74413r_state *st = gpiochip_get_data(chip);
|
||||
unsigned long real_mask = 0;
|
||||
@@ -309,15 +309,15 @@ static void ad74413r_gpio_set_multiple(struct gpio_chip *chip,
|
||||
ret = ad74413r_set_gpo_config(st, real_offset,
|
||||
AD74413R_GPO_CONFIG_LOGIC_PARALLEL);
|
||||
if (ret)
|
||||
return;
|
||||
return ret;
|
||||
|
||||
real_mask |= BIT(real_offset);
|
||||
if (*bits & offset)
|
||||
real_bits |= BIT(real_offset);
|
||||
}
|
||||
|
||||
regmap_update_bits(st->regmap, AD74413R_REG_GPO_PAR_DATA,
|
||||
real_mask, real_bits);
|
||||
return regmap_update_bits(st->regmap, AD74413R_REG_GPO_PAR_DATA,
|
||||
real_mask, real_bits);
|
||||
}
|
||||
|
||||
static int ad74413r_gpio_get(struct gpio_chip *chip, unsigned int offset)
|
||||
@@ -1424,8 +1424,8 @@ static int ad74413r_probe(struct spi_device *spi)
|
||||
st->gpo_gpiochip.ngpio = st->num_gpo_gpios;
|
||||
st->gpo_gpiochip.parent = st->dev;
|
||||
st->gpo_gpiochip.can_sleep = true;
|
||||
st->gpo_gpiochip.set = ad74413r_gpio_set;
|
||||
st->gpo_gpiochip.set_multiple = ad74413r_gpio_set_multiple;
|
||||
st->gpo_gpiochip.set_rv = ad74413r_gpio_set;
|
||||
st->gpo_gpiochip.set_multiple_rv = ad74413r_gpio_set_multiple;
|
||||
st->gpo_gpiochip.set_config = ad74413r_gpio_set_gpo_config;
|
||||
st->gpo_gpiochip.get_direction =
|
||||
ad74413r_gpio_get_gpo_direction;
|
||||
|
||||
Reference in New Issue
Block a user