Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

William Breathitt Gray and committed by
Linus Torvalds
608bd5fd 9f00ebf5

+6 -6
+6 -6
drivers/gpio/gpio-pisosr.c
··· 96 96 unsigned long *mask, unsigned long *bits) 97 97 { 98 98 struct pisosr_gpio *gpio = gpiochip_get_data(chip); 99 - unsigned int nbytes = DIV_ROUND_UP(chip->ngpio, 8); 100 - unsigned int i, j; 99 + unsigned long offset; 100 + unsigned long gpio_mask; 101 + unsigned long buffer_state; 101 102 102 103 pisosr_gpio_refresh(gpio); 103 104 104 105 bitmap_zero(bits, chip->ngpio); 105 - for (i = 0; i < nbytes; i++) { 106 - j = i / sizeof(unsigned long); 107 - bits[j] |= ((unsigned long) gpio->buffer[i]) 108 - << (8 * (i % sizeof(unsigned long))); 106 + for_each_set_clump8(offset, gpio_mask, mask, chip->ngpio) { 107 + buffer_state = gpio->buffer[offset / 8] & gpio_mask; 108 + bitmap_set_value8(bits, buffer_state, offset); 109 109 } 110 110 111 111 return 0;