diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2014-11-06 14:17:43 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-11-17 16:34:16 +0000 |
commit | 5fad6d4b8c0958f7d2a795215b31c22235babb45 (patch) | |
tree | e6a4ac5cda90ae4c3d9b42ae11c403c609fd6d46 | |
parent | 1d4c619a0afa9e69f5ae571e34e348d0598b023b (diff) | |
download | chrome-ec-5fad6d4b8c0958f7d2a795215b31c22235babb45.tar.gz |
util: Fix return value of ec_command
When ec_command fails because of transport issue,
it should returns an error between -1 and -EECRESULT.
If the command fails because of the EC, the error should be less
than -EECRESULT.
Unify all transports to return the error in the same manner.
BRANCH=ToT
BUG=None
TEST=Samus: Check that unsupported command fails with the correct error
number over dev transport.
Qwarks: Check the same command with a 3.10 kernel (no dev transport,
just LPC) fails with the same error code.
Change-Id: I2e43d0cb003d75318b0edd3745e534c700d7d7d8
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/228295
Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r-- | util/comm-i2c.c | 4 | ||||
-rw-r--r-- | util/comm-lpc.c | 4 | ||||
-rw-r--r-- | util/comm-mec1322.c | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/util/comm-i2c.c b/util/comm-i2c.c index aa1e4f64d8..0631220caf 100644 --- a/util/comm-i2c.c +++ b/util/comm-i2c.c @@ -140,8 +140,8 @@ static int ec_command_i2c(int command, int version, if (ret) { debug("command 0x%02x returned an error %d\n", command, i2c_msg[1].buf[0]); - /* Translate ERROR to -ERROR */ - ret = -ret; + /* Translate ERROR to -ERROR and offset */ + ret = -EECRESULT - ret; } else if (insize) { debug("i2c resp :"); /* copy response packet payload and compute checksum */ diff --git a/util/comm-lpc.c b/util/comm-lpc.c index 06912af1f2..e7c5a25b55 100644 --- a/util/comm-lpc.c +++ b/util/comm-lpc.c @@ -83,7 +83,7 @@ static int ec_command_lpc(int command, int version, i = inb(EC_LPC_ADDR_HOST_DATA); if (i) { fprintf(stderr, "EC returned error result code %d\n", i); - return -i; + return -EECRESULT - i; } /* Read back args */ @@ -178,7 +178,7 @@ static int ec_command_lpc_3(int command, int version, i = inb(EC_LPC_ADDR_HOST_DATA); if (i) { fprintf(stderr, "EC returned error result code %d\n", i); - return -i; + return -EECRESULT - i; } /* Read back response header and start checksum */ diff --git a/util/comm-mec1322.c b/util/comm-mec1322.c index 70e4f3ff89..61c93e184b 100644 --- a/util/comm-mec1322.c +++ b/util/comm-mec1322.c @@ -148,7 +148,7 @@ static int ec_command_lpc(int command, int version, i = read_byte(EC_LPC_ADDR_HOST_DATA); if (i) { fprintf(stderr, "EC returned error result code %d\n", i); - return -i; + return -EECRESULT - i; } /* Read back args */ @@ -236,7 +236,7 @@ static int ec_command_lpc_3(int command, int version, i = read_byte(EC_LPC_ADDR_HOST_DATA); if (i) { fprintf(stderr, "EC returned error result code %d\n", i); - return -i; + return -EECRESULT - i; } /* Read back response header and start checksum */ |