mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-13 23:29:10 -04:00
gpio: aggregator: 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-10-bc4cfd38dae3@linaro.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
@@ -358,25 +358,30 @@ static void gpio_fwd_delay(struct gpio_chip *chip, unsigned int offset, int valu
|
||||
udelay(delay_us);
|
||||
}
|
||||
|
||||
static void gpio_fwd_set(struct gpio_chip *chip, unsigned int offset, int value)
|
||||
static int gpio_fwd_set(struct gpio_chip *chip, unsigned int offset, int value)
|
||||
{
|
||||
struct gpiochip_fwd *fwd = gpiochip_get_data(chip);
|
||||
int ret;
|
||||
|
||||
if (chip->can_sleep)
|
||||
gpiod_set_value_cansleep(fwd->descs[offset], value);
|
||||
ret = gpiod_set_value_cansleep(fwd->descs[offset], value);
|
||||
else
|
||||
gpiod_set_value(fwd->descs[offset], value);
|
||||
ret = gpiod_set_value(fwd->descs[offset], value);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (fwd->delay_timings)
|
||||
gpio_fwd_delay(chip, offset, value);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void gpio_fwd_set_multiple(struct gpiochip_fwd *fwd, unsigned long *mask,
|
||||
unsigned long *bits)
|
||||
static int gpio_fwd_set_multiple(struct gpiochip_fwd *fwd, unsigned long *mask,
|
||||
unsigned long *bits)
|
||||
{
|
||||
struct gpio_desc **descs = fwd_tmp_descs(fwd);
|
||||
unsigned long *values = fwd_tmp_values(fwd);
|
||||
unsigned int i, j = 0;
|
||||
unsigned int i, j = 0, ret;
|
||||
|
||||
for_each_set_bit(i, mask, fwd->chip.ngpio) {
|
||||
__assign_bit(j, values, test_bit(i, bits));
|
||||
@@ -384,26 +389,31 @@ static void gpio_fwd_set_multiple(struct gpiochip_fwd *fwd, unsigned long *mask,
|
||||
}
|
||||
|
||||
if (fwd->chip.can_sleep)
|
||||
gpiod_set_array_value_cansleep(j, descs, NULL, values);
|
||||
ret = gpiod_set_array_value_cansleep(j, descs, NULL, values);
|
||||
else
|
||||
gpiod_set_array_value(j, descs, NULL, values);
|
||||
ret = gpiod_set_array_value(j, descs, NULL, values);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void gpio_fwd_set_multiple_locked(struct gpio_chip *chip,
|
||||
unsigned long *mask, unsigned long *bits)
|
||||
static int gpio_fwd_set_multiple_locked(struct gpio_chip *chip,
|
||||
unsigned long *mask, unsigned long *bits)
|
||||
{
|
||||
struct gpiochip_fwd *fwd = gpiochip_get_data(chip);
|
||||
unsigned long flags;
|
||||
int ret;
|
||||
|
||||
if (chip->can_sleep) {
|
||||
mutex_lock(&fwd->mlock);
|
||||
gpio_fwd_set_multiple(fwd, mask, bits);
|
||||
ret = gpio_fwd_set_multiple(fwd, mask, bits);
|
||||
mutex_unlock(&fwd->mlock);
|
||||
} else {
|
||||
spin_lock_irqsave(&fwd->slock, flags);
|
||||
gpio_fwd_set_multiple(fwd, mask, bits);
|
||||
ret = gpio_fwd_set_multiple(fwd, mask, bits);
|
||||
spin_unlock_irqrestore(&fwd->slock, flags);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int gpio_fwd_set_config(struct gpio_chip *chip, unsigned int offset,
|
||||
@@ -533,8 +543,8 @@ static struct gpiochip_fwd *gpiochip_fwd_create(struct device *dev,
|
||||
chip->direction_output = gpio_fwd_direction_output;
|
||||
chip->get = gpio_fwd_get;
|
||||
chip->get_multiple = gpio_fwd_get_multiple_locked;
|
||||
chip->set = gpio_fwd_set;
|
||||
chip->set_multiple = gpio_fwd_set_multiple_locked;
|
||||
chip->set_rv = gpio_fwd_set;
|
||||
chip->set_multiple_rv = gpio_fwd_set_multiple_locked;
|
||||
chip->to_irq = gpio_fwd_to_irq;
|
||||
chip->base = -1;
|
||||
chip->ngpio = ngpios;
|
||||
|
||||
Reference in New Issue
Block a user