Handle file errors when device path gets unbound
occ-control was asserting when the hwmon path would get removed due to
device being unbound. This change will gracefully handle the path
getting removed / added back.
Tested on Raininer by unbind/bind of devices:
echo occ-hwmon.2 > /sys/bus/platform/drivers/occ-hwmon/unbind
echo occ-hwmon.2 > /sys/bus/platform/drivers/occ-hwmon/bind
Change-Id: I46fd2c2c54868ffb8183d3dc49cd0c2751165d3b
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/occ_manager.cpp b/occ_manager.cpp
index 78ac9f2..a3f246c 100644
--- a/occ_manager.cpp
+++ b/occ_manager.cpp
@@ -844,16 +844,33 @@
void Manager::getSensorValues(std::unique_ptr<Status>& occ)
{
- const fs::path fileName = occ->getHwmonPath();
+ static bool tracedError[8] = {0};
+ const fs::path sensorPath = occ->getHwmonPath();
const uint32_t id = occ->getOccInstanceID();
- // Read temperature sensors
- readTempSensors(fileName, id);
-
- if (occ->isMasterOcc())
+ if (fs::exists(sensorPath))
{
- // Read power sensors
- readPowerSensors(fileName, id);
+ // Read temperature sensors
+ readTempSensors(sensorPath, id);
+
+ if (occ->isMasterOcc())
+ {
+ // Read power sensors
+ readPowerSensors(sensorPath, id);
+ }
+ tracedError[id] = false;
+ }
+ else
+ {
+ if (!tracedError[id])
+ {
+ log<level::ERR>(
+ fmt::format(
+ "Manager::getSensorValues: OCC{} sensor path missing: {}",
+ id, sensorPath.c_str())
+ .c_str());
+ tracedError[id] = true;
+ }
}
return;