[PATCH 09/15] gpio: sandbox: Make sandbox_gpio_set_flags() set all flags

Patrick DELAUNAY patrick.delaunay at foss.st.com
Thu Jan 21 10:43:44 CET 2021


Hi Simon,

On 1/15/21 3:04 PM, Simon Glass wrote:
> Allow this function to see all flags, including the internal sandbox ones.
> This allows the tests to fully control the behaviour of the driver.
>
> To make this work, move the setting of GPIOD_EXT_HIGH -to where the flags
> are updated via driver model, rather than the sandbox 'back door'.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
>   drivers/gpio/sandbox.c | 21 ++++++++++++++-------
>   1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
> index ebc160cb849..11d4757abbb 100644
> --- a/drivers/gpio/sandbox.c
> +++ b/drivers/gpio/sandbox.c
> @@ -114,9 +114,7 @@ int sandbox_gpio_set_flags(struct udevice *dev, uint offset, ulong flags)
>   {
>   	struct gpio_state *state = get_gpio_state(dev, offset);
>   
> -	if (flags & GPIOD_IS_OUT_ACTIVE)
> -		flags |= GPIOD_EXT_HIGH;
> -	state->flags = (state->flags & GPIOD_SANDBOX_MASK) | flags;
> +	state->flags = flags;
>   
>   	return 0;
>   }
> @@ -213,17 +211,26 @@ static int sb_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
>   	return 0;
>   }
>   
> -static int sb_gpio_update_flags(struct udevice *dev, uint offset, ulong newf)
> +static int sb_gpio_update_flags(struct udevice *dev, uint offset, ulong flags)
>   {
> -	debug("%s: offset:%u, flags = %lx\n", __func__, offset, newf);
> +	debug("%s: offset:%u, flags = %lx\n", __func__, offset, flags);
> +	struct gpio_state *state = get_gpio_state(dev, offset);
> +
> +	if (flags & GPIOD_IS_OUT) {
> +		if (flags & GPIOD_IS_OUT_ACTIVE)
> +			flags |= GPIOD_EXT_HIGH;
> +		else
> +			flags &= ~GPIOD_EXT_HIGH;
> +	}

Here GPIOD_EXT_HIGH is fully managed with GPIOD_IS_OUT_ACTIVE.

So that correct my remark on function sandbox_gpio_set_flags() in 
previous patche

[PATCH 07/15] gpio: sandbox: Use a separate flag for the value


> +	state->flags = flags;
>   
> -	return sandbox_gpio_set_flags(dev, offset, newf);
> +	return 0;
>   }
>   
>   static int sb_gpio_get_flags(struct udevice *dev, uint offset, ulong *flagsp)
>   {
>   	debug("%s: offset:%u\n", __func__, offset);
> -	*flagsp = *get_gpio_flags(dev, offset);
> +	*flagsp = *get_gpio_flags(dev, offset) & ~GPIOD_SANDBOX_MASK;
>   
>   	return 0;
>   }


Reviewed-by: Patrick Delaunay <patrick.delaunay at foss.st.com>

Thanks

Patrick




More information about the U-Boot mailing list