mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
gpio: sim: 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-6-bc4cfd38dae3@linaro.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
98ce1eb1fd
commit
fe69bedc77
|
|
@ -120,12 +120,14 @@ static int gpio_sim_get(struct gpio_chip *gc, unsigned int offset)
|
|||
return !!test_bit(offset, chip->value_map);
|
||||
}
|
||||
|
||||
static void gpio_sim_set(struct gpio_chip *gc, unsigned int offset, int value)
|
||||
static int gpio_sim_set(struct gpio_chip *gc, unsigned int offset, int value)
|
||||
{
|
||||
struct gpio_sim_chip *chip = gpiochip_get_data(gc);
|
||||
|
||||
scoped_guard(mutex, &chip->lock)
|
||||
__assign_bit(offset, chip->value_map, value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_sim_get_multiple(struct gpio_chip *gc,
|
||||
|
|
@ -139,14 +141,16 @@ static int gpio_sim_get_multiple(struct gpio_chip *gc,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void gpio_sim_set_multiple(struct gpio_chip *gc,
|
||||
unsigned long *mask, unsigned long *bits)
|
||||
static int gpio_sim_set_multiple(struct gpio_chip *gc,
|
||||
unsigned long *mask, unsigned long *bits)
|
||||
{
|
||||
struct gpio_sim_chip *chip = gpiochip_get_data(gc);
|
||||
|
||||
scoped_guard(mutex, &chip->lock)
|
||||
bitmap_replace(chip->value_map, chip->value_map, bits, mask,
|
||||
gc->ngpio);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_sim_direction_output(struct gpio_chip *gc,
|
||||
|
|
@ -482,9 +486,9 @@ static int gpio_sim_add_bank(struct fwnode_handle *swnode, struct device *dev)
|
|||
gc->parent = dev;
|
||||
gc->fwnode = swnode;
|
||||
gc->get = gpio_sim_get;
|
||||
gc->set = gpio_sim_set;
|
||||
gc->set_rv = gpio_sim_set;
|
||||
gc->get_multiple = gpio_sim_get_multiple;
|
||||
gc->set_multiple = gpio_sim_set_multiple;
|
||||
gc->set_multiple_rv = gpio_sim_set_multiple;
|
||||
gc->direction_output = gpio_sim_direction_output;
|
||||
gc->direction_input = gpio_sim_direction_input;
|
||||
gc->get_direction = gpio_sim_get_direction;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user