gpio: pisosr: utilize the for_each_set_clump8 macro

Replace verbose implementation in get_multiple callback with
for_each_set_clump8 macro to simplify code and improve clarity.

Link: http://lkml.kernel.org/r/8a39ee772247d4b7d752b32dbacc06c1cdcb60b5.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Morten Hein Tiljeset <morten.tiljeset@prevas.dk>
Cc: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Mathias Duckeck <m.duckeck@kunbus.de>
Cc: Phil Reid <preid@electromag.com.au>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
William Breathitt Gray 2019-12-04 16:51:36 -08:00 committed by Linus Torvalds
parent 9f00ebf518
commit 608bd5fda6
1 changed files with 6 additions and 6 deletions

View File

@ -96,16 +96,16 @@ static int pisosr_gpio_get_multiple(struct gpio_chip *chip,
unsigned long *mask, unsigned long *bits) unsigned long *mask, unsigned long *bits)
{ {
struct pisosr_gpio *gpio = gpiochip_get_data(chip); struct pisosr_gpio *gpio = gpiochip_get_data(chip);
unsigned int nbytes = DIV_ROUND_UP(chip->ngpio, 8); unsigned long offset;
unsigned int i, j; unsigned long gpio_mask;
unsigned long buffer_state;
pisosr_gpio_refresh(gpio); pisosr_gpio_refresh(gpio);
bitmap_zero(bits, chip->ngpio); bitmap_zero(bits, chip->ngpio);
for (i = 0; i < nbytes; i++) { for_each_set_clump8(offset, gpio_mask, mask, chip->ngpio) {
j = i / sizeof(unsigned long); buffer_state = gpio->buffer[offset / 8] & gpio_mask;
bits[j] |= ((unsigned long) gpio->buffer[i]) bitmap_set_value8(bits, buffer_state, offset);
<< (8 * (i % sizeof(unsigned long)));
} }
return 0; return 0;