diff options
author | Wei-Ning Huang <wnhuang@google.com> | 2017-08-08 17:26:04 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-08-08 10:09:18 -0700 |
commit | 25d281a42bd1e3cbf997e658ff9ae784bbecea20 (patch) | |
tree | 8ce52a0741710dddcbc32e875fc7304f9f94d882 | |
parent | 02aa4ee1e5d73d65b9aae5915e284a2ff6ceadc6 (diff) | |
download | chrome-ec-25d281a42bd1e3cbf997e658ff9ae784bbecea20.tar.gz |
ectool: do not try other communication methods for none cros_ec devices
There are none cros_ec devices running EC codebase connected to
chromebook, which can be accessed by ectool with
`cros_ec --name=SOME_DEV ...`.
In the case when SOME_DEV is not found, do not fallback to other
communication methods such as LPC or I2C, since ectool will instead get
the reply of real cros_ec device.
BRANCH=none
BUG=b:64468324
TEST=on poppy, `ectool --name=cros_tp version` should show:
`Unable to establish host communication
Couldn't find EC`
Change-Id: I2ac232122e0f928703f7607da365d5c1dc6f7194
Signed-off-by: Wei-Ning Huang <wnhuang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/604977
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r-- | util/comm-host.c | 7 | ||||
-rw-r--r-- | util/ectool.c | 3 |
2 files changed, 9 insertions, 1 deletions
diff --git a/util/comm-host.c b/util/comm-host.c index 31ad56343e..9fc65ab634 100644 --- a/util/comm-host.c +++ b/util/comm-host.c @@ -10,6 +10,7 @@ #include <string.h> #include "comm-host.h" +#include "cros_ec_dev.h" #include "ec_commands.h" #include "misc_util.h" @@ -96,6 +97,11 @@ int comm_init(int interfaces, const char *device_name) !comm_init_dev(device_name)) goto init_ok; + /* Do not fallback to other communication methods if target is not a + * cros_ec device */ + if (strcmp(CROS_EC_DEV_NAME, device_name)) + goto init_failed; + /* Fallback to direct LPC on x86 */ if ((interfaces & COMM_LPC) && comm_init_lpc && !comm_init_lpc()) goto init_ok; @@ -104,6 +110,7 @@ int comm_init(int interfaces, const char *device_name) if ((interfaces & COMM_I2C) && comm_init_i2c && !comm_init_i2c()) goto init_ok; + init_failed: /* Give up */ fprintf(stderr, "Unable to establish host communication\n"); return 1; diff --git a/util/ectool.c b/util/ectool.c index 0319ea858c..449e4ec818 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -18,6 +18,7 @@ #include "battery.h" #include "comm-host.h" #include "compile_time_macros.h" +#include "cros_ec_dev.h" #include "ec_panicinfo.h" #include "ec_flash.h" #include "ectool.h" @@ -7335,7 +7336,7 @@ int main(int argc, char *argv[]) const struct command *cmd; int dev = 0; int interfaces = COMM_ALL; - char device_name[40] = "cros_ec"; + char device_name[40] = CROS_EC_DEV_NAME; int rv = 1; int parse_error = 0; char *e; |