summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2017-03-17 10:56:03 +0100
committerchrome-bot <chrome-bot@chromium.org>2017-03-18 14:24:51 -0700
commit253366b3afe7a1c26b18fa8ae6fb4f4e07a4e7c9 (patch)
treefd3ab1bbc422cc327fb21b7c07965a7c30e9044f
parent7814f3319e7331ae9f3313d2a04e14b0bc1f1a90 (diff)
downloadchrome-ec-253366b3afe7a1c26b18fa8ae6fb4f4e07a4e7c9.tar.gz
ectool: fix fan commands for older EC
When invoking ectool fan commands on older ECs not supporting EC_CMD_GET_FEATURES, the tool is choking on the lack of the command at the beginning of get_num_fans() and not going further. The regression was introduced by https://chromium-review.googlesource.com/c/359069/, let's go back to the old behavior for machines without feature bits and skip the EC_FEATURE_PWM_FAN check. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=b:35575890 TEST=on Buddy, run 'ectool pwmgetnumfans' and 'ectool pwmgetfanrpm all' and get results. Change-Id: Ie9255d4afc9fa95a55807c310e9593a28c2aadc1 Reviewed-on: https://chromium-review.googlesource.com/456598 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--util/ectool.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/util/ectool.c b/util/ectool.c
index 18a90366eb..00a2395bfc 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -1761,11 +1761,12 @@ static int get_num_fans(void)
int idx, rv;
struct ec_response_get_features r;
+ /*
+ * iff the EC supports the GET_FEATURES,
+ * check whether it has fan support enabled.
+ */
rv = ec_command(EC_CMD_GET_FEATURES, 0, NULL, 0, &r, sizeof(r));
- if (rv < 0)
- return rv;
-
- if (!(r.flags[0] & (1 << EC_FEATURE_PWM_FAN)))
+ if (rv == EC_SUCCESS && !(r.flags[0] & (1 << EC_FEATURE_PWM_FAN)))
return 0;
for (idx = 0; idx < EC_FAN_SPEED_ENTRIES; idx++) {