summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2018-10-26 18:31:54 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2018-10-29 09:10:38 +0100
commitbbc5410ff3a411872d6022e939db618efd67ab49 (patch)
tree9fe4bc4b05a89caab9b42e9bff566addfb22ada2 /commands
parent183502af192962b0187d6f2ddc6e6a68b38869d0 (diff)
downloadbarebox-bbc5410ff3a411872d6022e939db618efd67ab49.tar.gz
commands: gpio: Allow GPIOs to be specified by label
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/gpio.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/commands/gpio.c b/commands/gpio.c
index 3a2b862..951ad2c 100644
--- a/commands/gpio.c
+++ b/commands/gpio.c
@@ -20,14 +20,17 @@ static int get_gpio_and_value(int argc, char *argv[],
int *gpio, int *value)
{
const int count = value ? 3 : 2;
- int ret;
+ int ret = 0;
if (argc < count)
return COMMAND_ERROR_USAGE;
- ret = kstrtoint(argv[1], 0, gpio);
- if (ret < 0)
- return ret;
+ *gpio = gpio_find_by_label(argv[1]);
+ if (*gpio < 0) {
+ ret = kstrtoint(argv[1], 0, gpio);
+ if (ret < 0)
+ return ret;
+ }
if (value)
ret = kstrtoint(argv[2], 0, value);