From 253366b3afe7a1c26b18fa8ae6fb4f4e07a4e7c9 Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Fri, 17 Mar 2017 10:56:03 +0100 Subject: 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 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 Tested-by: Vincent Palatin Reviewed-by: Aaron Durbin Reviewed-by: Shawn N --- util/ectool.c | 9 +++++---- 1 file 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++) { -- cgit v1.2.1