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

gpio: 74x164: utilize the for_each_set_clump8 macro

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

Link: http://lkml.kernel.org/r/7ea2df7182a50a1136ca36edc46dffcb2446fd27.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Phil Reid <preid@electromag.com.au>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
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: Morten Hein Tiljeset <morten.tiljeset@prevas.dk>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Sean Nyekjaer <sean.nyekjaer@prevas.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
b2ca9ebf 17b60389

+9 -10
+9 -10
drivers/gpio/gpio-74x164.c
··· 6 6 * Copyright (C) 2010 Miguel Gaio <miguel.gaio@efixo.com> 7 7 */ 8 8 9 + #include <linux/bitops.h> 9 10 #include <linux/gpio/consumer.h> 10 11 #include <linux/gpio/driver.h> 11 12 #include <linux/module.h> ··· 73 72 unsigned long *bits) 74 73 { 75 74 struct gen_74x164_chip *chip = gpiochip_get_data(gc); 76 - unsigned int i, idx, shift; 77 - u8 bank, bankmask; 75 + unsigned long offset; 76 + unsigned long bankmask; 77 + size_t bank; 78 + unsigned long bitmask; 78 79 79 80 mutex_lock(&chip->lock); 80 - for (i = 0, bank = chip->registers - 1; i < chip->registers; 81 - i++, bank--) { 82 - idx = i / sizeof(*mask); 83 - shift = i % sizeof(*mask) * BITS_PER_BYTE; 84 - bankmask = mask[idx] >> shift; 85 - if (!bankmask) 86 - continue; 81 + for_each_set_clump8(offset, bankmask, mask, chip->registers * 8) { 82 + bank = chip->registers - 1 - offset / 8; 83 + bitmask = bitmap_get_value8(bits, offset) & bankmask; 87 84 88 85 chip->buffer[bank] &= ~bankmask; 89 - chip->buffer[bank] |= bankmask & (bits[idx] >> shift); 86 + chip->buffer[bank] |= bitmask; 90 87 } 91 88 __gen_74x164_write_config(chip); 92 89 mutex_unlock(&chip->lock);