Skip to content

Commit

Permalink
gpio-pisosr: add support for get_multiple
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Morten Hein Tiljeset authored and Linus Walleij committed Jul 29, 2018
1 parent 2b955b3 commit 40bb5d7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions drivers/gpio/gpio-pisosr.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* GNU General Public License version 2 for more details.
*/

#include <linux/bitmap.h>
#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/gpio/driver.h>
Expand Down Expand Up @@ -90,13 +92,33 @@ static int pisosr_gpio_get(struct gpio_chip *chip, unsigned offset)
return (gpio->buffer[offset / 8] >> (offset % 8)) & 0x1;
}

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;

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)));
}

return 0;
}

static const struct gpio_chip template_chip = {
.label = "pisosr-gpio",
.owner = THIS_MODULE,
.get_direction = pisosr_gpio_get_direction,
.direction_input = pisosr_gpio_direction_input,
.direction_output = pisosr_gpio_direction_output,
.get = pisosr_gpio_get,
.get_multiple = pisosr_gpio_get_multiple,
.base = -1,
.ngpio = DEFAULT_NGPIO,
.can_sleep = true,
Expand Down

0 comments on commit 40bb5d7

Please sign in to comment.