From: Patrice Chotard <patrice.chotard@foss.st.com>
To: <u-boot@lists.denx.de>
Cc: Patrice CHOTARD <patrice.chotard@foss.st.com>,
Patrick DELAUNAY <patrick.delaunay@foss.st.com>,
U-Boot STM32 <uboot-stm32@st-md-mailman.stormreply.com>,
Simon Glass <sjg@chromium.org>, Andrew Jeffery <andrew@aj.id.au>,
Eddie James <eajames@linux.ibm.com>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Samuel Holland <samuel@sholland.org>
Subject: [PATCH v3 1/4] gpio: Allow to print pin's label even for pin with GPIOF_FUNC function
Date: Tue, 30 Aug 2022 14:09:11 +0200 [thread overview]
Message-ID: <20220830120914.2329522-2-patrice.chotard@foss.st.com> (raw)
In-Reply-To: <20220830120914.2329522-1-patrice.chotard@foss.st.com>
Currently, if pin's function is GPIOF_FUNC, only "func" if displayed
without any other information. It would be interesting, if information is
available, to indicate which pinmuxing's name is used.
For example, for STM32 SoC's based platform, "gpio status" command
output :
before
Bank GPIOZ:
GPIOZ0: unused : 0 [ ]
GPIOZ1: unused : 0 [ ]
GPIOZ2: unused : 0 [ ]
GPIOZ3: unused : 0 [ ]
GPIOZ4: func
GPIOZ5: func
GPIOZ6: unused : 0 [ ]
GPIOZ7: unused : 0 [ ]
GPIOZ8: unknown
GPIOZ9: unknown
GPIOZ10: unknown
GPIOZ11: unknown
GPIOZ12: unknown
GPIOZ13: unknown
GPIOZ14: unknown
GPIOZ15: unknown
After
Bank GPIOZ:
GPIOZ0: unused : 0 [ ]
GPIOZ1: unused : 0 [ ]
GPIOZ2: unused : 0 [ ]
GPIOZ3: unused : 0 [ ]
GPIOZ4: func i2c4-0
GPIOZ5: func i2c4-0
GPIOZ6: unused : 0 [ ]
GPIOZ7: unused : 0 [ ]
GPIOZ8: unknown
GPIOZ9: unknown
GPIOZ10: unknown
GPIOZ11: unknown
GPIOZ12: unknown
GPIOZ13: unknown
GPIOZ14: unknown
GPIOZ15: unknown
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- add lost Simon Glass's reviewed-by during v1 review
drivers/gpio/gpio-uclass.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 0ed32b7217..d60e46159a 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -884,26 +884,31 @@ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize)
const struct dm_gpio_ops *ops = gpio_get_ops(dev);
struct gpio_dev_priv *priv;
char *str = buf;
+ const char *label;
int func;
int ret;
int len;
+ bool used;
BUILD_BUG_ON(GPIOF_COUNT != ARRAY_SIZE(gpio_function));
*buf = 0;
priv = dev_get_uclass_priv(dev);
- ret = gpio_get_raw_function(dev, offset, NULL);
+ ret = gpio_get_raw_function(dev, offset, &label);
if (ret < 0)
return ret;
func = ret;
len = snprintf(str, buffsize, "%s%d: %s",
priv->bank_name ? priv->bank_name : "",
offset, gpio_function[func]);
- if (func == GPIOF_INPUT || func == GPIOF_OUTPUT ||
- func == GPIOF_UNUSED) {
- const char *label;
- bool used;
+ switch (func) {
+ case GPIOF_FUNC:
+ snprintf(str + len, buffsize - len, " %s", label ? label : "");
+ break;
+ case GPIOF_INPUT:
+ case GPIOF_OUTPUT:
+ case GPIOF_UNUSED:
ret = ops->get_value(dev, offset);
if (ret < 0)
return ret;
@@ -913,6 +918,7 @@ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize)
used ? 'x' : ' ',
used ? " " : "",
label ? label : "");
+ break;
}
return 0;
--
2.25.1
next prev parent reply other threads:[~2022-08-30 12:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-30 12:09 [PATCH v3 0/4] gpio: update gpio_get_status() Patrice Chotard
2022-08-30 12:09 ` Patrice Chotard [this message]
2022-08-30 12:16 ` [PATCH v3 1/4] gpio: Allow to print pin's label even for pin with GPIOF_FUNC function Patrick DELAUNAY
2022-09-15 14:02 ` Tom Rini
2022-08-30 12:09 ` [PATCH v3 2/4] gpio: Fix pin's status display for pin with GPIOF_UNUSED function Patrice Chotard
2022-08-30 12:16 ` Patrick DELAUNAY
2022-09-15 14:03 ` Tom Rini
2022-08-30 12:09 ` [PATCH v3 3/4] pinctrl: pinctrl_stm32: Populate uc_priv->name[] with pinmux node's name Patrice Chotard
2022-08-30 12:21 ` Patrick DELAUNAY
2022-09-15 14:03 ` Tom Rini
2022-08-30 12:09 ` [PATCH v3 4/4] gpio: sandbox: Add GPIOD_IS_AF for gpio configured in alternate function Patrice Chotard
2022-08-30 12:24 ` Patrick DELAUNAY
2022-09-15 14:03 ` Tom Rini
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=20220830120914.2329522-2-patrice.chotard@foss.st.com \
--to=patrice.chotard@foss.st.com \
--cc=andrew@aj.id.au \
--cc=eajames@linux.ibm.com \
--cc=patrick.delaunay@foss.st.com \
--cc=samuel@sholland.org \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
--cc=uboot-stm32@st-md-mailman.stormreply.com \
--cc=xypron.glpk@gmx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).