[PATCH v2 2/2] cmd: pinmux: support pin name in status command
Simon Glass
sjg at chromium.org
Wed May 19 17:34:02 CEST 2021
Hi Patrick,
On Wed, 19 May 2021 at 06:30, Patrick Delaunay
<patrick.delaunay at foss.st.com> wrote:
>
> Allow pin name parameter for pimux staus command,
> as gpio command to get status of one pin.
>
> The possible usage of the command is:
>
> > pinmux dev pinctrl
> > pinmux status
>
> > pinmux status -a
>
> > pinmux status <pin-name>
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay at foss.st.com>
> ---
>
> Changes in v2:
> - use -ENOENT when the pin name is not found
> - move the added pytests in a C file cmd/pinmux.c
>
> cmd/pinmux.c | 38 +++++++++++++++++++++++++++++---------
> test/cmd/Makefile | 1 +
> test/cmd/pinmux.c | 36 ++++++++++++++++++++++++++++++++++++
> 3 files changed, 66 insertions(+), 9 deletions(-)
> create mode 100644 test/cmd/pinmux.c
Reviewed-by: Simon Glass <sjg at chromium.org>
nit below
>
> diff --git a/cmd/pinmux.c b/cmd/pinmux.c
> index 0df78c71da..527d33d562 100644
> --- a/cmd/pinmux.c
> +++ b/cmd/pinmux.c
> @@ -41,13 +41,14 @@ static int do_dev(struct cmd_tbl *cmdtp, int flag, int argc,
> return CMD_RET_SUCCESS;
> }
>
> -static int show_pinmux(struct udevice *dev)
> +static int show_pinmux(struct udevice *dev, char *name)
Can you add a comment indicating what these args are (and that @name
can be NULL) and return values?
> {
> char pin_name[PINNAME_SIZE];
> char pin_mux[PINMUX_SIZE];
> int pins_count;
> int i;
> int ret;
> + bool found = false;
>
> pins_count = pinctrl_get_pins_count(dev);
>
> @@ -62,7 +63,9 @@ static int show_pinmux(struct udevice *dev)
> printf("Ops get_pin_name error (%d) by %s\n", ret, dev->name);
> return ret;
> }
> -
> + if (name && strcmp(name, pin_name))
> + continue;
> + found = true;
> ret = pinctrl_get_pin_muxing(dev, i, pin_mux, PINMUX_SIZE);
> if (ret) {
> printf("Ops get_pin_muxing error (%d) by %s in %s\n",
> @@ -74,6 +77,9 @@ static int show_pinmux(struct udevice *dev)
> PINMUX_SIZE, pin_mux);
> }
>
> + if (!found)
> + return -ENOENT;
> +
> return 0;
> }
>
> @@ -81,24 +87,38 @@ static int do_status(struct cmd_tbl *cmdtp, int flag, int argc,
> char *const argv[])
> {
> struct udevice *dev;
> + char *name;
> + int ret;
>
> if (argc < 2) {
> if (!currdev) {
> printf("pin-controller device not selected\n");
> return CMD_RET_FAILURE;
> }
> - show_pinmux(currdev);
> + show_pinmux(currdev, NULL);
> return CMD_RET_SUCCESS;
> }
>
> if (strcmp(argv[1], "-a"))
> - return CMD_RET_USAGE;
> + name = argv[1];
> + else
> + name = NULL;
>
[..]
Regards,
Simon
More information about the U-Boot
mailing list