From: =?utf-8?B?SnVsaWVuIELDqXJhdWQ=?= Date: Sat, 5 Jan 2019 13:19:12 +0000 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: <1c9dc354-e706-e496-f697-ff0b354b437c@orolia.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 > On 1/4/19 5:48 PM, Julien B=C3=A9raud wrote: >> gpio_get_value should return 0 or 1, not 1 << pin > > Is this documented somewhere ? I should have mentioned that the following code in cmd/gpio.c expects it and displays a warning else. ... gpio_direction_output(gpio, value); } printf("gpio: pin %s (gpio %i) value is ", str_gpio, gpio); int nval =3D gpio_get_value(gpio); if (IS_ERR_VALUE(nval)) printf(" Warning: no access to GPIO output value\n"); else if (nval !=3D value) printf(" Warning: value of pin is still %d\n", nval); ... So with the current altera pio code, calling "gpio set N" with N !=3D 0 prints a warning "value of pin is still 1 << N" >> - return readl(®s->data) & (1 << pin); >> + return (readl(®s->data) >> pin) & 1; > > return !!(..condition..); Sure. I'll resend. Julien