All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cmd: gpio: Make `gpio input` return pin value again
@ 2020-03-10 10:32 Alex Kiernan
  2020-03-11  1:56 ` Simon Glass
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Kiernan @ 2020-03-10 10:32 UTC (permalink / raw)
  To: u-boot

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 <alex.kiernan@gmail.com>
---

 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)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] cmd: gpio: Make `gpio input` return pin value again
  2020-03-10 10:32 [PATCH] cmd: gpio: Make `gpio input` return pin value again Alex Kiernan
@ 2020-03-11  1:56 ` Simon Glass
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2020-03-11  1:56 UTC (permalink / raw)
  To: u-boot

On Tue, 10 Mar 2020 at 04:33, Alex Kiernan <alex.kiernan@gmail.com> wrote:
>
> 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 <alex.kiernan@gmail.com>
> ---
>
>  cmd/gpio.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

Please also add a test for this.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-11  1:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-10 10:32 [PATCH] cmd: gpio: Make `gpio input` return pin value again Alex Kiernan
2020-03-11  1:56 ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.