diff options
author | Caveh Jalali <caveh@chromium.org> | 2018-04-05 22:22:27 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-04-10 19:13:11 -0700 |
commit | 396750a226e991b81af0afd52637b599dc6f27fa (patch) | |
tree | 94f243339ffea1a7665382f25f9973f474d82a46 | |
parent | 9466bef89bc45b30e12e74438469e630fe2c6091 (diff) | |
download | chrome-ec-396750a226e991b81af0afd52637b599dc6f27fa.tar.gz |
battery: treat error codes properly
the "cutoff" command would print "Invalid argument" which is
EC_invalid but the underlying funciton actually returned EC_RES_ERROR,
so we need to map the error codes from the EC_RES_* (enum ec_status)
number space to the EC_ERROR_* (enum ec_error_list) number space.
BUG=none
BRANCH=none
TEST=cutoff command now prints "Unknown error" instead of "Unimplemented".
Change-Id: I0b2928e629cc859bc3ba5587bf6c7fd70e1084d7
Signed-off-by: Caveh Jalali <caveh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/999102
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Caveh Jalali <caveh@google.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | common/battery.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/common/battery.c b/common/battery.c index 365278d79d..9252fb9a94 100644 --- a/common/battery.c +++ b/common/battery.c @@ -292,7 +292,7 @@ static void pending_cutoff_deferred(void) rv = board_cut_off_battery(); - if (rv == EC_SUCCESS) + if (rv == EC_RES_SUCCESS) CPRINTF("[%T Battery cut off succeeded.]\n"); else CPRINTF("[%T Battery cut off failed!]\n"); @@ -323,7 +323,7 @@ static int battery_command_cutoff(struct host_cmd_handler_args *args) } rv = board_cut_off_battery(); - if (!rv) { + if (rv == EC_RES_SUCCESS) { CPRINTS("Battery cut off is successful."); battery_cutoff_state = BATTERY_CUTOFF_STATE_CUT_OFF; } else { @@ -360,12 +360,13 @@ static int command_cutoff(int argc, char **argv) } rv = board_cut_off_battery(); - if (!rv) { + if (rv == EC_RES_SUCCESS) { ccprintf("[%T Battery cut off]\n"); battery_cutoff_state = BATTERY_CUTOFF_STATE_CUT_OFF; + return EC_SUCCESS; } - return rv; + return EC_ERROR_UNKNOWN; } DECLARE_CONSOLE_COMMAND(cutoff, command_cutoff, "[at-shutdown]", |