Initialize the wctemp/modelNumber of struct NVMeData
Avoid to set unexpected value for wctemp/modelNumber
and also set thresholds when they're different from the
previous one
Signed-off-by: George Hung <george.hung@quantatw.com>
Signed-off-by: Brandon Kim <brandonkim@google.com>
Change-Id: Ib5247dcc0b20c017cefba5eac61a92638310d0b5
diff --git a/nvme_manager.cpp b/nvme_manager.cpp
index 02bc819..9ceed7c 100644
--- a/nvme_manager.cpp
+++ b/nvme_manager.cpp
@@ -214,10 +214,12 @@
nvmeData.present = true;
nvmeData.vendor = "";
nvmeData.serialNumber = "";
+ nvmeData.modelNumber = "";
nvmeData.smartWarnings = "";
nvmeData.statusFlags = "";
nvmeData.driveLifeUsed = "";
nvmeData.sensorValue = (int8_t)TEMPERATURE_SENSOR_FAILURE;
+ nvmeData.wcTemp = 0;
phosphor::smbus::Smbus smbus;
@@ -503,7 +505,7 @@
std::string inventoryPath;
std::map<sdbusplus::message::object_path, Interfaces> obj;
- for (const auto config : configs)
+ for (const auto& config : configs)
{
inventoryPath = "/system/chassis/motherboard/nvme" + config.index;
@@ -547,8 +549,8 @@
config.criticalHigh = nvmeData.wcTemp;
config.warningHigh = nvmeData.wcTemp;
}
+ nvmeSSD->setSensorMaxMin(config.maxValue, config.minValue);
nvmeSSD->setSensorThreshold(config.criticalHigh, config.criticalLow,
- config.maxValue, config.minValue,
config.warningHigh, config.warningLow);
nvmeSSD->checkSensorThreshold();
@@ -558,6 +560,12 @@
{
setNvmeInventoryProperties(true, nvmeData, inventoryPath);
iter->second->setSensorValueToDbus(nvmeData.sensorValue);
+ if (nvmeData.wcTemp != 0)
+ {
+ iter->second->setSensorThreshold(
+ config.criticalHigh, config.criticalLow, config.warningHigh,
+ config.warningLow);
+ }
iter->second->checkSensorThreshold();
setLEDsStatus(config, success, nvmeData);
}