From: Heinrich Schuchardt Date: Mon, 14 Sep 2020 10:50:55 +0000 (+0200) Subject: drivers: gpio: keep output value for input on sandbox X-Git-Tag: v2021.10~484^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7cd96a47281145aca4f9c8960a0a2e185b8bd70c;p=platform%2Fkernel%2Fu-boot.git drivers: gpio: keep output value for input on sandbox 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 Reviewed-by: Philippe Reynes --- diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c index c2f8047..eb2600d 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; }