diff options
author | Vic Yang <victoryang@chromium.org> | 2012-05-21 16:34:44 +0800 |
---|---|---|
committer | Vic Yang <victoryang@chromium.org> | 2012-05-21 16:46:59 +0800 |
commit | bc021ce9c7007d0848d338df84f46aadfb54fa2f (patch) | |
tree | 9ea414c2f10d395fc12eacadc65303f98cac1030 /common/thermal.c | |
parent | 36107b54d45d9e79c09936a686661f8b83bc8708 (diff) | |
download | chrome-ec-bc021ce9c7007d0848d338df84f46aadfb54fa2f.tar.gz |
Fix a bug that 'ectool thermalget' silently fails
'ectool thermalget' should return error if sensor ID or threshold ID is
out of range. This CL fixes a bug that error codes mismatch.
BUG=chrome-os-partner:9840
TEST='ectool thermalget 0 10' gives error.
Change-Id: I74d0c66044cd31743c4fac0a8dc0431db6259e71
Diffstat (limited to 'common/thermal.c')
-rw-r--r-- | common/thermal.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/common/thermal.c b/common/thermal.c index 9aa3e5d066..72709cd8ec 100644 --- a/common/thermal.c +++ b/common/thermal.c @@ -57,11 +57,13 @@ static int fan_ctrl_on = 1; int thermal_set_threshold(enum temp_sensor_type type, int threshold_id, int value) { + if (type < 0 || type >= TEMP_SENSOR_TYPE_COUNT) + return -1; if (threshold_id < 0 || threshold_id >= THRESHOLD_COUNT + THERMAL_FAN_STEPS) - return EC_ERROR_INVAL; + return -1; if (value < 0) - return EC_ERROR_INVAL; + return -1; thermal_config[type].thresholds[threshold_id] = value; @@ -71,9 +73,11 @@ int thermal_set_threshold(enum temp_sensor_type type, int threshold_id, int valu int thermal_get_threshold(enum temp_sensor_type type, int threshold_id) { + if (type < 0 || type >= TEMP_SENSOR_TYPE_COUNT) + return -1; if (threshold_id < 0 || threshold_id >= THRESHOLD_COUNT + THERMAL_FAN_STEPS) - return EC_ERROR_INVAL; + return -1; return thermal_config[type].thresholds[threshold_id]; } |