Skip to content

Commit

Permalink
gpio: sim: fix setting and getting multiple lines
Browse files Browse the repository at this point in the history
We need to take mask into account in the set/get_multiple() callbacks.
Use bitmap_replace() instead of bitmap_copy().

Fixes: cb8c474 ("gpio: sim: new testing module")
Cc: stable@vger.kernel.org
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  • Loading branch information
Bartosz Golaszewski committed Apr 14, 2022
1 parent ce522ba commit 3836c73
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/gpio/gpio-sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static int gpio_sim_get_multiple(struct gpio_chip *gc,
struct gpio_sim_chip *chip = gpiochip_get_data(gc);

mutex_lock(&chip->lock);
bitmap_copy(bits, chip->value_map, gc->ngpio);
bitmap_replace(bits, bits, chip->value_map, mask, gc->ngpio);
mutex_unlock(&chip->lock);

return 0;
Expand All @@ -146,7 +146,7 @@ static void gpio_sim_set_multiple(struct gpio_chip *gc,
struct gpio_sim_chip *chip = gpiochip_get_data(gc);

mutex_lock(&chip->lock);
bitmap_copy(chip->value_map, bits, gc->ngpio);
bitmap_replace(chip->value_map, chip->value_map, bits, mask, gc->ngpio);
mutex_unlock(&chip->lock);
}

Expand Down

0 comments on commit 3836c73

Please sign in to comment.