Skip to content

Commit

Permalink
gpio: bcm-virt: Fix the get() method
Browse files Browse the repository at this point in the history
The get() method does not understand the on-the-wire encoding of the
remote GPIO states, thinking they are simple on/off bits when they are
really pairs of 16-bit counts. Rewrite the get() handler to return the
value last written, which will eventually match the actual GPIO state
if there are no other changes.

See: #4638

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
  • Loading branch information
pelwell committed Oct 19, 2021
1 parent 908c60c commit 5314a55
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-bcm-virt.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static int brcmvirt_gpio_get(struct gpio_chip *gc, unsigned off)
unsigned v;
gpio = container_of(gc, struct brcmvirt_gpio, gc);
v = readl(gpio->ts_base + off);
return (v >> off) & 1;
return (s16)((v >> 16) - v) > 0;
}

static void brcmvirt_gpio_set(struct gpio_chip *gc, unsigned off, int val)
Expand Down

0 comments on commit 5314a55

Please sign in to comment.