From: Matti Vaittinen Date: Mon, 7 Apr 2025 07:30:47 +0000 (+0300) Subject: iio: bd79124: Use set_rv and set_multiple_rv X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=a34b88b48a15f5d49207966fa78e14e71e16ac6c;p=linux-2.6-microblaze.git iio: bd79124: Use set_rv and set_multiple_rv The new GPIO callbacks 'set_rv' and 'set_multiple_rv' allow returning a success code to indicate failures when setting GPIO status. Use them to allow callers to know when things go south. Signed-off-by: Matti Vaittinen Link: https://patch.msgid.link/Z_N_J52IZ2IaWawl@mva-rohm Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/adc/rohm-bd79124.c b/drivers/iio/adc/rohm-bd79124.c index 13673f4347d4..bb7c93ae4055 100644 --- a/drivers/iio/adc/rohm-bd79124.c +++ b/drivers/iio/adc/rohm-bd79124.c @@ -196,17 +196,18 @@ static int bd79124gpo_direction_get(struct gpio_chip *gc, unsigned int offset) return GPIO_LINE_DIRECTION_OUT; } -static void bd79124gpo_set(struct gpio_chip *gc, unsigned int offset, int value) +static int bd79124gpo_set(struct gpio_chip *gc, unsigned int offset, int value) { struct bd79124_data *data = gpiochip_get_data(gc); - regmap_assign_bits(data->map, BD79124_REG_GPO_VAL, BIT(offset), value); + return regmap_assign_bits(data->map, BD79124_REG_GPO_VAL, BIT(offset), + value); } -static void bd79124gpo_set_multiple(struct gpio_chip *gc, unsigned long *mask, +static int bd79124gpo_set_multiple(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits) { - unsigned int all_gpos, set_gpos; + unsigned int all_gpos; int ret; struct bd79124_data *data = gpiochip_get_data(gc); @@ -219,17 +220,15 @@ static void bd79124gpo_set_multiple(struct gpio_chip *gc, unsigned long *mask, */ ret = regmap_read(data->map, BD79124_REG_PINCFG, &all_gpos); if (ret) - return; + return ret; if (all_gpos ^ *mask) { dev_dbg(data->dev, "Invalid mux config. Can't set value.\n"); - /* Do not set value for pins configured as ADC inputs */ - set_gpos = *mask & all_gpos; - } else { - set_gpos = *mask; + + return -EINVAL; } - regmap_update_bits(data->map, BD79124_REG_GPO_VAL, set_gpos, *bits); + return regmap_update_bits(data->map, BD79124_REG_GPO_VAL, *mask, *bits); } static int bd79124_init_valid_mask(struct gpio_chip *gc, @@ -247,8 +246,8 @@ static int bd79124_init_valid_mask(struct gpio_chip *gc, static const struct gpio_chip bd79124gpo_chip = { .label = "bd79124-gpo", .get_direction = bd79124gpo_direction_get, - .set = bd79124gpo_set, - .set_multiple = bd79124gpo_set_multiple, + .set_rv = bd79124gpo_set, + .set_multiple_rv = bd79124gpo_set_multiple, .init_valid_mask = bd79124_init_valid_mask, .can_sleep = true, .ngpio = 8,