From patchwork Tue Mar 10 10:32:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 243478 List-Id: U-Boot discussion From: alex.kiernan at gmail.com (Alex Kiernan) Date: Tue, 10 Mar 2020 10:32:49 +0000 Subject: [PATCH] cmd: gpio: Make `gpio input` return pin value again Message-ID: <20200310103249.65203-1-alex.kiernan@gmail.com> 4dbc107f4683 ("cmd: gpio: Correct do_gpio() return value") correctly changed the behaviour of the gpio command to return CMD_RET_SUCCESS or CMD_RET_FAILURE. But any existing script which expects the return value to be the pin value is broken by this change. Reinstate the legacy behaviour for `gpio input` only. Fixes: 4dbc107f4683 ("cmd: gpio: Correct do_gpio() return value") Signed-off-by: Alex Kiernan Reviewed-by: Simon Glass --- cmd/gpio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/gpio.c b/cmd/gpio.c index 16c2cebb3d4b..b716f6f18b95 100644 --- a/cmd/gpio.c +++ b/cmd/gpio.c @@ -248,7 +248,11 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (ret != -EBUSY) gpio_free(gpio); - return CMD_RET_SUCCESS; + /* + * Whilst wrong, the legacy gpio input command returns the pin value + * (or CMD_RET_FAILURE) + */ + return (sub_cmd == GPIOC_INPUT) ? value : CMD_RET_SUCCESS; err: if (ret != -EBUSY)