
Currently we return the GPIO value directly as command exit code. In shell exit codes, 0 means success. Hence if a GPIO is one, we actually return a "failure". Fix this by returning SUCCESS if the value is positive.
This allows to implement scripts more naturally e.g.: if gpio input 47; then echo "Pressed"; else echo "Not pressed"; fi
Signed-off-by: Stefan Agner stefan@agner.ch --- Not sure if it is the right thing to do to change that, maybe there are a lot of users which rely on that output already?
It just feels a bit more natural to me when using the command in scripts...
-- Stefan
common/cmd_gpio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/common/cmd_gpio.c b/common/cmd_gpio.c index 65d6df4..ed735bd 100644 --- a/common/cmd_gpio.c +++ b/common/cmd_gpio.c @@ -208,7 +208,10 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (ret != -EBUSY) gpio_free(gpio);
- return value; + if (value) + return CMD_RET_SUCCESS; + else + return CMD_RET_FAILURE; }
U_BOOT_CMD(gpio, 4, 0, do_gpio,