From: Simon Goldschmidt Date: Sat, 5 Jan 2019 09:34:16 +0100 Subject: [U-Boot] [PATCH 1/1] altera_pio: fix get_value In-Reply-To: <2a0b5391-8f94-66f4-35f9-dd2c4f37c51b@denx.de> References: <20190104164834.6249-1-julien.beraud@orolia.com> <2a0b5391-8f94-66f4-35f9-dd2c4f37c51b@denx.de> Message-ID: <6c497b10-1337-c7dd-5628-5f2e124796de@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Am 04.01.2019 um 19:53 schrieb Marek Vasut: > On 1/4/19 5:48 PM, Julien B=C3=A9raud wrote: >> gpio_get_value should return 0 or 1, not 1 << pin >=20 > Is this documented somewhere ? I saw it's kind of documented on 'dm_gpio_get_value', but not on struct=20 dm_gpio_ops: "@return GPIO value (0 for inactive, 1 for active) or -ve on error" Regards, Simon >=20 >> Signed-off-by: Julien Beraud >> --- >> drivers/gpio/altera_pio.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/gpio/altera_pio.c b/drivers/gpio/altera_pio.c >> index 59e30979f0..997c32e56d 100644 >> --- a/drivers/gpio/altera_pio.c >> +++ b/drivers/gpio/altera_pio.c >> @@ -56,7 +56,7 @@ static int altera_pio_get_value(struct udevice *dev, u= nsigned pin) >> struct altera_pio_platdata *plat =3D dev_get_platdata(dev); >> struct altera_pio_regs *const regs =3D plat->regs; >> =20 >> - return readl(®s->data) & (1 << pin); >> + return (readl(®s->data) >> pin) & 1; >=20 > return !!(..condition..); >=20 >> } >> =20 >> =20 >> >=20 >=20