aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Breathitt Gray <[email protected]>2019-12-04 16:51:36 -0800
committerLinus Torvalds <[email protected]>2019-12-04 19:44:13 -0800
commit608bd5fda60d9e2083c8bb92f17adfae73afc37a (patch)
treeb916165bcf5fc305e943921393f09038197768dc
parent9f00ebf518b80e4d58ab32966772b68511d015f2 (diff)
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 <[email protected]> Cc: Andy Shevchenko <[email protected]> Cc: Morten Hein Tiljeset <[email protected]> Cc: Sean Nyekjaer <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Bartosz Golaszewski <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Linus Walleij <[email protected]> Cc: Lukas Wunner <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: Mathias Duckeck <[email protected]> Cc: Phil Reid <[email protected]> Cc: Rasmus Villemoes <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--drivers/gpio/gpio-pisosr.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c
index 1331b2a94679..6698feabaced 100644
--- a/drivers/gpio/gpio-pisosr.c
+++ b/drivers/gpio/gpio-pisosr.c
@@ -96,16 +96,16 @@ static int pisosr_gpio_get_multiple(struct gpio_chip *chip,
unsigned long *mask, unsigned long *bits)
{
struct pisosr_gpio *gpio = gpiochip_get_data(chip);
- unsigned int nbytes = DIV_ROUND_UP(chip->ngpio, 8);
- unsigned int i, j;
+ unsigned long offset;
+ unsigned long gpio_mask;
+ unsigned long buffer_state;
pisosr_gpio_refresh(gpio);
bitmap_zero(bits, chip->ngpio);
- for (i = 0; i < nbytes; i++) {
- j = i / sizeof(unsigned long);
- bits[j] |= ((unsigned long) gpio->buffer[i])
- << (8 * (i % sizeof(unsigned long)));
+ for_each_set_clump8(offset, gpio_mask, mask, chip->ngpio) {
+ buffer_state = gpio->buffer[offset / 8] & gpio_mask;
+ bitmap_set_value8(bits, buffer_state, offset);
}
return 0;