All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick DELAUNAY <patrick.delaunay@foss.st.com>
To: u-boot@lists.denx.de
Subject: [PATCH 09/15] gpio: sandbox: Make sandbox_gpio_set_flags() set all flags
Date: Thu, 21 Jan 2021 10:43:44 +0100	[thread overview]
Message-ID: <23a04992-03d7-00c1-342e-488187de8789@foss.st.com> (raw)
In-Reply-To: <20210115140500.846307-10-sjg@chromium.org>

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@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@foss.st.com>

Thanks

Patrick

  reply	other threads:[~2021-01-21  9:43 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-15 14:04 [PATCH 00/15] gpio: Update and simplify the uclass API Simon Glass
2021-01-15 14:04 ` [PATCH 01/15] gpio: Disable functions not used with of-platdata Simon Glass
2021-01-18 21:17   ` Pratyush Yadav
2021-01-21  8:59   ` Patrick DELAUNAY
2021-01-15 14:04 ` [PATCH 02/15] dm: gpio: Rename set_dir_flags() method to update_flags() Simon Glass
2021-01-18 21:39   ` Pratyush Yadav
2021-01-21  9:01   ` Patrick DELAUNAY
2021-01-15 14:04 ` [PATCH 03/15] dm: gpio: Rename get_dir_flags() method to get_flags() Simon Glass
2021-01-18 21:54   ` Pratyush Yadav
2021-01-21  9:02   ` Patrick DELAUNAY
2021-01-15 14:04 ` [PATCH 04/15] gpio: Rename dm_gpio_get_dir_flags() to dm_gpio_get_flags() Simon Glass
2021-01-18 21:57   ` Pratyush Yadav
2021-01-21  9:05   ` Patrick DELAUNAY
2021-01-15 14:04 ` [PATCH 05/15] gpio: Drop dm_gpio_set_dir() Simon Glass
2021-01-21  9:06   ` Patrick DELAUNAY
2021-01-15 14:04 ` [PATCH 06/15] gpio: sandbox: Rename GPIO dir_flags to flags Simon Glass
2021-01-21  9:14   ` Patrick DELAUNAY
2021-01-15 14:04 ` [PATCH 07/15] gpio: sandbox: Use a separate flag for the value Simon Glass
2021-01-21  9:33   ` Patrick DELAUNAY
2021-01-15 14:04 ` [PATCH 08/15] gpio: sandbox: Fully separate pin value from output value Simon Glass
2021-01-21  9:39   ` Patrick DELAUNAY
2021-01-15 14:04 ` [PATCH 09/15] gpio: sandbox: Make sandbox_gpio_set_flags() set all flags Simon Glass
2021-01-21  9:43   ` Patrick DELAUNAY [this message]
2021-01-15 14:04 ` [PATCH 10/15] dm: gpio: Add a way to update flags Simon Glass
2021-01-21 10:07   ` Patrick DELAUNAY
2021-01-15 14:04 ` [PATCH 11/15] gpio: Replace direction_input() and direction_output() Simon Glass
2021-01-21 10:12   ` Patrick DELAUNAY
2021-01-15 14:04 ` [PATCH 12/15] gpio: Use an 'ops' variable everywhere Simon Glass
2021-01-21 10:13   ` Patrick DELAUNAY
2021-01-15 14:04 ` [PATCH 13/15] gpio: x86: Drop the deprecated methods in intel_gpio Simon Glass
2021-01-15 14:04 ` [PATCH 14/15] gpio: sandbox: Track whether a GPIO is driven Simon Glass
2021-01-21 10:19   ` Patrick DELAUNAY
2021-01-15 14:05 ` [PATCH 15/15] gpio: Add a way to read 3-way strapping pins Simon Glass
2021-01-21 10:52   ` Patrick DELAUNAY

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23a04992-03d7-00c1-342e-488187de8789@foss.st.com \
    --to=patrick.delaunay@foss.st.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.