Factor out getPowerState() helper function
This same pattern had been open-coded in many of the sensor daemons;
let's reduce the duplication a bit.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I8556af30fdcd53cdf06e5a4911f9152d3265c7af
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index 988e8b9..d1d50d6 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -400,14 +400,7 @@
}
}
- auto findPowerOn = baseConfigMap.find("PowerState");
- PowerState readState = PowerState::always;
- if (findPowerOn != baseConfigMap.end())
- {
- std::string powerState =
- std::visit(VariantToStringVisitor(), findPowerOn->second);
- setReadState(powerState, readState);
- }
+ PowerState readState = getPowerState(baseConfigMap);
auto permitSet = getPermitSet(baseConfigMap);
auto& sensor = sensors[sensorName];