mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 10:45:22 +00:00
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
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user