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

gpio-pisosr: add support for get_multiple

Signed-off-by: Morten Hein Tiljeset <morten.tiljeset@prevas.dk>
Reviewed-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Morten Hein Tiljeset and committed by
Linus Walleij
40bb5d72 2b955b34

+22
+22
drivers/gpio/gpio-pisosr.c
··· 12 12 * GNU General Public License version 2 for more details. 13 13 */ 14 14 15 + #include <linux/bitmap.h> 16 + #include <linux/bitops.h> 15 17 #include <linux/delay.h> 16 18 #include <linux/gpio/consumer.h> 17 19 #include <linux/gpio/driver.h> ··· 92 90 return (gpio->buffer[offset / 8] >> (offset % 8)) & 0x1; 93 91 } 94 92 93 + static int pisosr_gpio_get_multiple(struct gpio_chip *chip, 94 + unsigned long *mask, unsigned long *bits) 95 + { 96 + struct pisosr_gpio *gpio = gpiochip_get_data(chip); 97 + unsigned int nbytes = DIV_ROUND_UP(chip->ngpio, 8); 98 + unsigned int i, j; 99 + 100 + pisosr_gpio_refresh(gpio); 101 + 102 + bitmap_zero(bits, chip->ngpio); 103 + for (i = 0; i < nbytes; i++) { 104 + j = i / sizeof(unsigned long); 105 + bits[j] |= ((unsigned long) gpio->buffer[i]) 106 + << (8 * (i % sizeof(unsigned long))); 107 + } 108 + 109 + return 0; 110 + } 111 + 95 112 static const struct gpio_chip template_chip = { 96 113 .label = "pisosr-gpio", 97 114 .owner = THIS_MODULE, ··· 118 97 .direction_input = pisosr_gpio_direction_input, 119 98 .direction_output = pisosr_gpio_direction_output, 120 99 .get = pisosr_gpio_get, 100 + .get_multiple = pisosr_gpio_get_multiple, 121 101 .base = -1, 122 102 .ngpio = DEFAULT_NGPIO, 123 103 .can_sleep = true,