From: Sascha Hauer <sha@pengutronix.de>
To: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>, barebox@lists.infradead.org
Subject: Re: [PATCH 4/5] commands: gpio: add -d argument to set/get commands
Date: Wed, 28 Sep 2022 16:36:31 +0200 [thread overview]
Message-ID: <20220928143631.GX986@pengutronix.de> (raw)
In-Reply-To: <lyv8p7wrfp.fsf@ensc-pc.intern.sigma-chemnitz.de>
Hi Enrico,
On Wed, Sep 28, 2022 at 03:37:30PM +0200, Enrico Scholz wrote:
> Ahmad Fatoum <a.fatoum@pengutronix.de> writes:
>
> > For debugging, it can be useful to reference GPIOs relative to a
> > controller, e.g.:
> >
> > gpio_direction_output -d gpio4 20 1
> >
> > - if (argc < count)
> > + if (optind < count)
> > return COMMAND_ERROR_USAGE;
>
> This change seems to make '-d ...' mandatory. E.g.
>
> | :/ gpio_get_value 65
> |
> | gpio_get_value - return value of a GPIO pin
> |
> | Usage: gpio_get_value [-d CONTROLLER] GPIO
>
Thanks for reporting. Here is a fix for that
Sascha
-----------------------------8<---------------------------
>From 7c797eb87385522ce1ec1ba44315ba386d82978d Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Wed, 28 Sep 2022 16:33:21 +0200
Subject: [PATCH] gpio: Fix gpio commands called without -d option
04443dc5fc breaks the calculation of arguments needed which effectively
makes the -d option mandatory. Fix this.
Fixes: 04443dc5fc ("commands: gpio: add -d argument to set/get commands")
Reported-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/gpio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/commands/gpio.c b/commands/gpio.c
index d04fd65bc8..5e5eb20583 100644
--- a/commands/gpio.c
+++ b/commands/gpio.c
@@ -11,7 +11,7 @@ static int get_gpio_and_value(int argc, char *argv[],
{
struct gpio_chip *chip = NULL;
struct device_d *dev;
- int count = 2;
+ int count = 1;
int ret = 0;
int opt;
@@ -34,7 +34,7 @@ static int get_gpio_and_value(int argc, char *argv[],
if (value)
count++;
- if (optind < count)
+ if (argc < optind + count)
return COMMAND_ERROR_USAGE;
*gpio = gpio_find_by_name(argv[optind]);
--
2.30.2
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2022-09-28 14:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-05 10:35 [PATCH 0/5] commands: gpio: add controller as optional argument Ahmad Fatoum
2022-09-05 10:35 ` [PATCH 1/5] gpiolib: implement gpio_get_chip_by_dev() Ahmad Fatoum
2022-09-05 10:35 ` [PATCH 2/5] of: platform: optimize of_find_device_by_node when deep probing Ahmad Fatoum
2022-09-05 10:35 ` [PATCH 3/5] driver: implement find_device() helper Ahmad Fatoum
2022-09-05 10:35 ` [PATCH 4/5] commands: gpio: add -d argument to set/get commands Ahmad Fatoum
2022-09-28 13:37 ` Enrico Scholz
2022-09-28 14:36 ` Sascha Hauer [this message]
2022-09-29 9:50 ` Ahmad Fatoum
2022-09-05 10:35 ` [PATCH 5/5] gpiolib: gpioinfo: add optional CONTROLLER command line argument Ahmad Fatoum
2022-09-28 13:22 ` Enrico Scholz
2022-09-28 14:24 ` Sascha Hauer
2022-09-12 9:13 ` [PATCH 0/5] commands: gpio: add controller as optional argument Sascha Hauer
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=20220928143631.GX986@pengutronix.de \
--to=sha@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=enrico.scholz@sigma-chemnitz.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