diff mbox series

[v2,2/3] drivers: gpio: keep output value for input on sandbox

Message ID 20200914105056.174287-3-xypron.glpk@gmx.de
State Accepted
Commit 7cd96a47281145aca4f9c8960a0a2e185b8bd70c
Delegated to: Tom Rini
Headers show
Series cmd/button: return button status | expand

Commit Message

Heinrich Schuchardt Sept. 14, 2020, 10:50 a.m. UTC
For testing purposes keep the output value when switching to input.
This allows us to manipulate the input value via the gpio command.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2:
	new patch
---
 drivers/gpio/sandbox.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

--
2.28.0

Comments

Philippe REYNES Sept. 14, 2020, 4:01 p.m. UTC | #1
> For testing purposes keep the output value when switching to input.
> This allows us to manipulate the input value via the gpio command.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Reviewed-by: Philippe Reynes <philippe.reynes@softathome.com>

> ---
> v2:
> new patch
> ---
> drivers/gpio/sandbox.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
> index c2f80472b8..eb2600de31 100644
> --- a/drivers/gpio/sandbox.c
> +++ b/drivers/gpio/sandbox.c
> @@ -185,7 +185,15 @@ static int sb_gpio_set_dir_flags(struct udevice *dev,
> unsigned int offset,
> 
> dir_flags = get_gpio_dir_flags(dev, offset);
> 
> - *dir_flags = flags;
> + /*
> + * For testing purposes keep the output value when switching to input.
> + * This allows us to manipulate the input value via the gpio command.
> + */
> + if (flags & GPIOD_IS_IN)
> + *dir_flags = (flags & ~GPIOD_IS_OUT_ACTIVE) |
> + (*dir_flags & GPIOD_IS_OUT_ACTIVE);
> + else
> + *dir_flags = flags;
> 
> return 0;
> }
> --
> 2.28.0
Tom Rini Oct. 14, 2020, 5:42 p.m. UTC | #2
On Mon, Sep 14, 2020 at 12:50:55PM +0200, Heinrich Schuchardt wrote:

> For testing purposes keep the output value when switching to input.
> This allows us to manipulate the input value via the gpio command.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Reviewed-by: Philippe Reynes <philippe.reynes@softathome.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
index c2f80472b8..eb2600de31 100644
--- a/drivers/gpio/sandbox.c
+++ b/drivers/gpio/sandbox.c
@@ -185,7 +185,15 @@  static int sb_gpio_set_dir_flags(struct udevice *dev, unsigned int offset,

 	dir_flags = get_gpio_dir_flags(dev, offset);

-	*dir_flags = flags;
+	/*
+	 * For testing purposes keep the output value when switching to input.
+	 * This allows us to manipulate the input value via the gpio command.
+	 */
+	if (flags & GPIOD_IS_IN)
+		*dir_flags = (flags & ~GPIOD_IS_OUT_ACTIVE) |
+			     (*dir_flags & GPIOD_IS_OUT_ACTIVE);
+	else
+		*dir_flags = flags;

 	return 0;
 }