Skip to contentSkip to conversation

cmd: gpio: Make `gpio input` return pin value again

PATCH Superseded Alex Kiernan 2 participants 2 messages Mar 10, 2020 – Mar 11, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: gpio: Make `gpio input` return pin value again

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

---

 cmd/gpio.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
cmd/gpio.c +5 -1
index 16c2cebb3d4b..b716f6f18b95 100644
@@ -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)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 cmd: gpio: Make `gpio input` return pin value again

Quoted 8 lines · Alex Kiernan

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.

Quoted 8 lines

Reinstate the legacy behaviour for gpio input only.

Fixes 4dbc107f4683 ("cmd: gpio: Correct do_gpio() return value")

---

 cmd/gpio.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Please also add a test for this.