diff mbox

[U-Boot,08/10] i2c: Correct command return values

Message ID 1451391772-6203-9-git-send-email-sjg@chromium.org
State Accepted
Commit 4fbd258e69373a60cdf24c9a64065b486f8748c9
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass Dec. 29, 2015, 12:22 p.m. UTC
We should not return a -ve error code from command functions. Instead,
return CMD_RET_FAILURE. This avoids the "exit not allowed from main input
shell" error messages from the hush shell.

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

 common/cmd_i2c.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Heiko Schocher Jan. 4, 2016, 7:08 a.m. UTC | #1
Hello Simon,

Am 29.12.2015 um 13:22 schrieb Simon Glass:
> We should not return a -ve error code from command functions. Instead,
> return CMD_RET_FAILURE. This avoids the "exit not allowed from main input
> shell" error messages from the hush shell.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>   common/cmd_i2c.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)

Thanks! As it is in a patchserie:

Acked-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
> index 552c875..b3bb644 100644
> --- a/common/cmd_i2c.c
> +++ b/common/cmd_i2c.c
> @@ -1809,7 +1809,8 @@ static int do_i2c_bus_num(cmd_tbl_t *cmdtp, int flag, int argc,
>   		if (ret)
>   			printf("Failure changing bus number (%d)\n", ret);
>   	}
> -	return ret;
> +
> +	return ret ? CMD_RET_FAILURE : 0;
>   }
>   #endif  /* defined(CONFIG_SYS_I2C) */
>
> @@ -1852,7 +1853,8 @@ static int do_i2c_bus_speed(cmd_tbl_t * cmdtp, int flag, int argc, char * const
>   		if (ret)
>   			printf("Failure changing bus speed (%d)\n", ret);
>   	}
> -	return ret;
> +
> +	return ret ? CMD_RET_FAILURE : 0;
>   }
>
>   /**
>
Simon Glass Jan. 16, 2016, 1:25 a.m. UTC | #2
On 4 January 2016 at 00:08, Heiko Schocher <hs@denx.de> wrote:
> Hello Simon,
>
> Am 29.12.2015 um 13:22 schrieb Simon Glass:
>>
>> We should not return a -ve error code from command functions. Instead,
>> return CMD_RET_FAILURE. This avoids the "exit not allowed from main input
>> shell" error messages from the hush shell.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>   common/cmd_i2c.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>
>
> Thanks! As it is in a patchserie:
>
> Acked-by: Heiko Schocher <hs@denx.de>
>

Applied to u-boot-dm!
diff mbox

Patch

diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index 552c875..b3bb644 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -1809,7 +1809,8 @@  static int do_i2c_bus_num(cmd_tbl_t *cmdtp, int flag, int argc,
 		if (ret)
 			printf("Failure changing bus number (%d)\n", ret);
 	}
-	return ret;
+
+	return ret ? CMD_RET_FAILURE : 0;
 }
 #endif  /* defined(CONFIG_SYS_I2C) */
 
@@ -1852,7 +1853,8 @@  static int do_i2c_bus_speed(cmd_tbl_t * cmdtp, int flag, int argc, char * const
 		if (ret)
 			printf("Failure changing bus speed (%d)\n", ret);
 	}
-	return ret;
+
+	return ret ? CMD_RET_FAILURE : 0;
 }
 
 /**