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>
This commit is contained in:
Vincent Palatin
2017-03-17 10:56:03 +01:00
committed by chrome-bot
parent 7814f3319e
commit 253366b3af

View File

@@ -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++) {