* [U-Boot] [PATCH 1/2] GPIO: pca953x: fix spelling in help @ 2012-07-25 13:55 Laurence Withers 2012-07-25 13:55 ` [U-Boot] [PATCH 2/2] GPIO: pca953x: fix error reporting Laurence Withers 2012-10-05 22:03 ` [U-Boot] [PATCH 1/2] GPIO: pca953x: fix spelling in help Anatolij Gustschin 0 siblings, 2 replies; 4+ messages in thread From: Laurence Withers @ 2012-07-25 13:55 UTC (permalink / raw) To: u-boot Signed-off-by: Laurence Withers <lwithers@guralp.com> --- drivers/gpio/pca953x.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c index 359fdee..64c7797 100644 --- a/drivers/gpio/pca953x.c +++ b/drivers/gpio/pca953x.c @@ -287,7 +287,7 @@ U_BOOT_CMD( " - set pin as output and drive low or high\n" "pca953x invert pin 0|1\n" " - disable/enable polarity inversion for reads\n" - "pca953x intput pin\n" + "pca953x input pin\n" " - set pin as input and read value" ); -- 1.7.2.5 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 2/2] GPIO: pca953x: fix error reporting 2012-07-25 13:55 [U-Boot] [PATCH 1/2] GPIO: pca953x: fix spelling in help Laurence Withers @ 2012-07-25 13:55 ` Laurence Withers 2012-10-05 22:04 ` Anatolij Gustschin 2012-10-05 22:03 ` [U-Boot] [PATCH 1/2] GPIO: pca953x: fix spelling in help Anatolij Gustschin 1 sibling, 1 reply; 4+ messages in thread From: Laurence Withers @ 2012-07-25 13:55 UTC (permalink / raw) To: u-boot Use the standard CMD_RET_* constants to clearly report errors from the pca953x command. In addition, print error messages when I2C communication fails. Signed-off-by: Laurence Withers <lwithers@guralp.com> --- drivers/gpio/pca953x.c | 49 ++++++++++++++++++++++++++++++++++------------- 1 files changed, 35 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c index 64c7797..be13745 100644 --- a/drivers/gpio/pca953x.c +++ b/drivers/gpio/pca953x.c @@ -221,7 +221,7 @@ cmd_tbl_t cmd_pca953x[] = { int do_pca953x(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { static uint8_t chip = CONFIG_SYS_I2C_PCA953X_ADDR; - int val; + int ret = CMD_RET_USAGE, val; ulong ul_arg2 = 0; ulong ul_arg3 = 0; cmd_tbl_t *c; @@ -232,7 +232,7 @@ int do_pca953x(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (!c || !((argc == (c->maxargs)) || (((int)c->cmd == PCA953X_CMD_DEVICE) && (argc == (c->maxargs - 1))))) { - return cmd_usage(cmdtp); + return CMD_RET_USAGE; } /* arg2 used as chip number or pin number */ @@ -246,32 +246,53 @@ int do_pca953x(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) switch ((int)c->cmd) { #ifdef CONFIG_CMD_PCA953X_INFO case PCA953X_CMD_INFO: - return pca953x_info(chip); + ret = pca953x_info(chip); + if (ret) + ret = CMD_RET_FAILURE; + break; #endif + case PCA953X_CMD_DEVICE: if (argc == 3) chip = (uint8_t)ul_arg2; printf("Current device address: 0x%x\n", chip); - return 0; + ret = CMD_RET_SUCCESS; + break; + case PCA953X_CMD_INPUT: - pca953x_set_dir(chip, (1 << ul_arg2), + ret = pca953x_set_dir(chip, (1 << ul_arg2), PCA953X_DIR_IN << ul_arg2); val = (pca953x_get_val(chip) & (1 << ul_arg2)) != 0; - printf("chip 0x%02x, pin 0x%lx = %d\n", chip, ul_arg2, val); - return val; + if (ret) + ret = CMD_RET_FAILURE; + else + printf("chip 0x%02x, pin 0x%lx = %d\n", chip, ul_arg2, + val); + break; + case PCA953X_CMD_OUTPUT: - pca953x_set_dir(chip, (1 << ul_arg2), + ret = pca953x_set_dir(chip, (1 << ul_arg2), (PCA953X_DIR_OUT << ul_arg2)); - return pca953x_set_val(chip, (1 << ul_arg2), - (ul_arg3 << ul_arg2)); + if (!ret) + ret = pca953x_set_val(chip, (1 << ul_arg2), + (ul_arg3 << ul_arg2)); + if (ret) + ret = CMD_RET_FAILURE; + break; + case PCA953X_CMD_INVERT: - return pca953x_set_pol(chip, (1 << ul_arg2), + ret = pca953x_set_pol(chip, (1 << ul_arg2), (ul_arg3 << ul_arg2)); - default: - /* We should never get here */ - return 1; + if (ret) + ret = CMD_RET_FAILURE; + break; } + + if (ret == CMD_RET_FAILURE) + eprintf("Error talking to chip@0x%x\n", chip); + + return ret; } U_BOOT_CMD( -- 1.7.2.5 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 2/2] GPIO: pca953x: fix error reporting 2012-07-25 13:55 ` [U-Boot] [PATCH 2/2] GPIO: pca953x: fix error reporting Laurence Withers @ 2012-10-05 22:04 ` Anatolij Gustschin 0 siblings, 0 replies; 4+ messages in thread From: Anatolij Gustschin @ 2012-10-05 22:04 UTC (permalink / raw) To: u-boot Hi, On Wed, 25 Jul 2012 13:55:48 +0000 Laurence Withers <lwithers@guralp.com> wrote: > Use the standard CMD_RET_* constants to clearly report errors from the > pca953x command. In addition, print error messages when I2C communication > fails. > > Signed-off-by: Laurence Withers <lwithers@guralp.com> > --- > drivers/gpio/pca953x.c | 49 ++++++++++++++++++++++++++++++++++------------- > 1 files changed, 35 insertions(+), 14 deletions(-) Applied to staging/agust at denx.de. Thanks, Anatolij ^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 1/2] GPIO: pca953x: fix spelling in help 2012-07-25 13:55 [U-Boot] [PATCH 1/2] GPIO: pca953x: fix spelling in help Laurence Withers 2012-07-25 13:55 ` [U-Boot] [PATCH 2/2] GPIO: pca953x: fix error reporting Laurence Withers @ 2012-10-05 22:03 ` Anatolij Gustschin 1 sibling, 0 replies; 4+ messages in thread From: Anatolij Gustschin @ 2012-10-05 22:03 UTC (permalink / raw) To: u-boot Hi, On Wed, 25 Jul 2012 13:55:47 +0000 Laurence Withers <lwithers@guralp.com> wrote: > Signed-off-by: Laurence Withers <lwithers@guralp.com> > --- > drivers/gpio/pca953x.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) Applied to staging/agust at denx.de. Thanks, Anatolij ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-10-05 22:04 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-07-25 13:55 [U-Boot] [PATCH 1/2] GPIO: pca953x: fix spelling in help Laurence Withers 2012-07-25 13:55 ` [U-Boot] [PATCH 2/2] GPIO: pca953x: fix error reporting Laurence Withers 2012-10-05 22:04 ` Anatolij Gustschin 2012-10-05 22:03 ` [U-Boot] [PATCH 1/2] GPIO: pca953x: fix spelling in help Anatolij Gustschin
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.