diff options
author | Gerrit <chrome-bot@google.com> | 2012-05-21 09:11:01 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@gerrit.golo.chromium.org> | 2012-05-21 09:11:01 -0700 |
commit | 8407b93f6ddbd1533adc87a650913c4581a15f41 (patch) | |
tree | 6afc56fa43c4fb2da6b683f424e2948b6a4c1043 | |
parent | d0b9c233734ea0e7445d664fcec296fa9496bd0b (diff) | |
parent | bc021ce9c7007d0848d338df84f46aadfb54fa2f (diff) | |
download | chrome-ec-8407b93f6ddbd1533adc87a650913c4581a15f41.tar.gz |
Merge "Fix a bug that 'ectool thermalget' silently fails"
-rw-r--r-- | common/thermal.c | 10 | ||||
-rw-r--r-- | common/thermal_commands.c | 5 |
2 files changed, 10 insertions, 5 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]; } diff --git a/common/thermal_commands.c b/common/thermal_commands.c index aedbf63f80..f4bb8d6497 100644 --- a/common/thermal_commands.c +++ b/common/thermal_commands.c @@ -28,10 +28,11 @@ int thermal_command_get_threshold(uint8_t *data, int *resp_size) (struct ec_params_thermal_get_threshold *)data; struct ec_response_thermal_get_threshold *r = (struct ec_response_thermal_get_threshold *)data; + int value = thermal_get_threshold(p->sensor_type, p->threshold_id); - r->value = thermal_get_threshold(p->sensor_type, p->threshold_id); - if (r->value == -1) + if (value == -1) return EC_RES_ERROR; + r->value = value; *resp_size = sizeof(struct ec_response_thermal_get_threshold); return EC_RES_SUCCESS; |