From mboxrd@z Thu Jan 1 00:00:00 1970 From: Patrick DELAUNAY Date: Thu, 21 Jan 2021 10:14:19 +0100 Subject: [PATCH 06/15] gpio: sandbox: Rename GPIO dir_flags to flags In-Reply-To: <20210115140500.846307-7-sjg@chromium.org> References: <20210115140500.846307-1-sjg@chromium.org> <20210115140500.846307-7-sjg@chromium.org> Message-ID: <9bb35d55-2383-01cb-e23c-80a783209ec8@foss.st.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Simon, On 1/15/21 3:04 PM, Simon Glass wrote: > Adjust the terminology in this driver to reflect that fact that all flags > are handled, not just direction flags. > > Create a new access function to get the full GPIO state, not just the > direction flags. Drop the static invalid_dir_flags since we can rely on a > segfault if something is wrong. If I remember, I add this static vairable? to avoid crash during normal pytest.... But it is more the case with the serie, it is better to drop it. > > Signed-off-by: Simon Glass > --- > > arch/sandbox/include/asm/gpio.h | 8 ++-- > drivers/gpio/sandbox.c | 65 ++++++++++++++++++--------------- > test/dm/gpio.c | 18 ++++----- > 3 files changed, 49 insertions(+), 42 deletions(-) > > diff --git a/arch/sandbox/include/asm/gpio.h b/arch/sandbox/include/asm/gpio.h > index df4ba4fb5f3..20d78296551 100644 > --- a/arch/sandbox/include/asm/gpio.h > +++ b/arch/sandbox/include/asm/gpio.h > @@ -69,17 +69,17 @@ int sandbox_gpio_set_direction(struct udevice *dev, unsigned int offset, > * @param offset GPIO offset within bank > * @return dir_flags: bitfield accesses by GPIOD_ defines > */ > -ulong sandbox_gpio_get_dir_flags(struct udevice *dev, unsigned int offset); > +ulong sandbox_gpio_get_flags(struct udevice *dev, unsigned int offset); > (...) > > -/* Access routines for GPIO dir flags */ > -static ulong *get_gpio_dir_flags(struct udevice *dev, unsigned int offset) > +/* Access routines for GPIO info */ > +static struct gpio_state *get_gpio_state(struct udevice *dev, uint offset) > { > struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); > struct gpio_state *state = dev_get_priv(dev); > > if (offset >= uc_priv->gpio_count) { > - static ulong invalid_dir_flags; > printf("sandbox_gpio: error: invalid gpio %u\n", offset); > - return &invalid_dir_flags; > + return NULL; > } > > - return &state[offset].dir_flags; > + return &state[offset]; > +} > + > +/* Access routines for GPIO dir flags */ /* Access routines for GPIO flags */ > +static ulong *get_gpio_flags(struct udevice *dev, unsigned int offset) > +{ > + struct gpio_state *state = get_gpio_state(dev, offset); > + > + if (!state) > + return NULL; > + > + return &state->flags; > > } > (...) With comment Reviewed-by: Patrick Delaunay Thanks Patrick