summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-09-28 16:33:21 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-09-28 16:33:47 +0200
commit7c797eb87385522ce1ec1ba44315ba386d82978d (patch)
tree195062cb3d635eb780d84bfee83b47ae967ce65a
parent252c76cdf8c9d516589d72ac228ac0d19fcb2021 (diff)
downloadbarebox-7c797eb87385522ce1ec1ba44315ba386d82978d.tar.gz
barebox-7c797eb87385522ce1ec1ba44315ba386d82978d.tar.xz
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>
-rw-r--r--commands/gpio.c4
1 files 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]);