thermal-hal: Use correct threshold severity index
Use the correct threshold severity Index when populating and retrieving
the threshold.
Change-Id: Ifec69778e69d9d480018782ee446a12ab5089a10
diff --git a/thermalCommon.cpp b/thermalCommon.cpp
index 2e981dd..6fb0d03 100644
--- a/thermalCommon.cpp
+++ b/thermalCommon.cpp
@@ -241,24 +241,24 @@
sensor.thresh.type = sensor.t.type = cfg.type;
sensor.thresh.vrThrottlingThreshold =
UNKNOWN_TEMPERATURE;
- for (idx = 0; idx < (size_t)ThrottlingSeverity::SHUTDOWN; idx++) {
+ for (idx = 0; idx <= (size_t)ThrottlingSeverity::SHUTDOWN; idx++) {
sensor.thresh.hotThrottlingThresholds[idx] =
sensor.thresh.coldThrottlingThresholds[idx] =
UNKNOWN_TEMPERATURE;
}
if (cfg.throt_thresh != 0 && cfg.positive_thresh_ramp)
- sensor.thresh.hotThrottlingThresholds[(size_t)ThrottlingSeverity::SEVERE - 1] =
+ sensor.thresh.hotThrottlingThresholds[(size_t)ThrottlingSeverity::SEVERE] =
cfg.throt_thresh / (float)sensor.mulFactor;
else if (cfg.throt_thresh != 0 && !cfg.positive_thresh_ramp)
- sensor.thresh.coldThrottlingThresholds[(size_t)ThrottlingSeverity::SEVERE - 1] =
+ sensor.thresh.coldThrottlingThresholds[(size_t)ThrottlingSeverity::SEVERE] =
cfg.throt_thresh / (float)sensor.mulFactor;
if (cfg.shutdwn_thresh != 0 && cfg.positive_thresh_ramp)
- sensor.thresh.hotThrottlingThresholds[(size_t)ThrottlingSeverity::SHUTDOWN - 1] =
+ sensor.thresh.hotThrottlingThresholds[(size_t)ThrottlingSeverity::SHUTDOWN] =
cfg.shutdwn_thresh / (float)sensor.mulFactor;
else if (cfg.shutdwn_thresh != 0 && !cfg.positive_thresh_ramp)
- sensor.thresh.coldThrottlingThresholds[(size_t)ThrottlingSeverity::SHUTDOWN - 1] =
+ sensor.thresh.coldThrottlingThresholds[(size_t)ThrottlingSeverity::SHUTDOWN] =
cfg.shutdwn_thresh / (float)sensor.mulFactor;
if (cfg.vr_thresh != 0)
@@ -396,7 +396,7 @@
ThrottlingSeverity severity = ThrottlingSeverity::NONE;
float temp = sensor->t.value;
- for (idx = (int)ThrottlingSeverity::SHUTDOWN - 1; idx >= 0; idx--) {
+ for (idx = (int)ThrottlingSeverity::SHUTDOWN; idx >= 0; idx--) {
if ((sensor->positiveThresh &&
!isnan(sensor->thresh.hotThrottlingThresholds[idx]) &&
temp >=
@@ -408,7 +408,7 @@
break;
}
if (idx >= 0)
- severity = (ThrottlingSeverity)(idx + 1);
+ severity = (ThrottlingSeverity)(idx);
LOG(DEBUG) << "Sensor Name:" << sensor->t.name << ". old severity:" <<
(int)sensor->t.throttlingStatus << " New severity:" <<
(int)severity << std::endl;
@@ -472,9 +472,9 @@
}
next_trip = UNKNOWN_TEMPERATURE;
- for (idx = 0;idx < (int)ThrottlingSeverity::SHUTDOWN; idx++) {
+ for (idx = 0;idx <= (int)ThrottlingSeverity::SHUTDOWN; idx++) {
if (isnan(sensor.thresh.hotThrottlingThresholds[idx])
- || idx <= ((int)sensor.t.throttlingStatus) - 1)
+ || idx <= (int)sensor.t.throttlingStatus)
continue;
next_trip = sensor.thresh.hotThrottlingThresholds[idx] *
@@ -491,7 +491,7 @@
}
if (sensor.t.throttlingStatus != ThrottlingSeverity::NONE) {
curr_trip = sensor.thresh.hotThrottlingThresholds[
- (int)sensor.t.throttlingStatus - 1]
+ (int)sensor.t.throttlingStatus]
* sensor.mulFactor;
if (!isnan(next_trip))
hyst_temp = (next_trip - curr_trip) + DEFAULT_HYSTERESIS;
diff --git a/thermalUtils.cpp b/thermalUtils.cpp
index b26d512..7aaada4 100644
--- a/thermalUtils.cpp
+++ b/thermalUtils.cpp
@@ -126,9 +126,9 @@
_temp.name = sens.t.name;
_temp.type = (TemperatureType_1_0)sens.t.type;
_temp.throttlingThreshold = sens.thresh.hotThrottlingThresholds[
- (size_t)ThrottlingSeverity::SEVERE - 1];
+ (size_t)ThrottlingSeverity::SEVERE];
_temp.shutdownThreshold = sens.thresh.hotThrottlingThresholds[
- (size_t)ThrottlingSeverity::SHUTDOWN - 1];
+ (size_t)ThrottlingSeverity::SHUTDOWN];
_temp.vrThrottlingThreshold = sens.thresh.vrThrottlingThreshold;
_temp_v.push_back(_temp);
}