Remove Configuration interface prefix from utils APIs
This eliminates some repetitive verbosity from daemons that handle a lot
of different sensor types (such as hwmontempsensor and psusensor). It
also positions us to more cleanly use a single data structure for both
existing APIs like GetSensorConfiguration() and
setupPropertiesChangedMatches(), as well as upcoming I2C
device-management support.
Tested: hwmontempsensor and adcsensor on romed8hm3 continue to behave as
they did previously.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I9d80475ca4160c8d2ff0afab942709496d51238d
diff --git a/src/FanMain.cpp b/src/FanMain.cpp
index 6732575..4e7542b 100644
--- a/src/FanMain.cpp
+++ b/src/FanMain.cpp
@@ -40,10 +40,8 @@
namespace fs = std::filesystem;
// The following two structures need to be consistent
-static auto sensorTypes{std::to_array<const char*>(
- {"xyz.openbmc_project.Configuration.AspeedFan",
- "xyz.openbmc_project.Configuration.I2CFan",
- "xyz.openbmc_project.Configuration.NuvotonFan"})};
+static auto sensorTypes{
+ std::to_array<const char*>({"AspeedFan", "I2CFan", "NuvotonFan"})};
enum FanTypes
{
@@ -237,6 +235,7 @@
fs::path directory = path.parent_path();
FanTypes fanType = getFanType(directory);
+ std::string cfgIntf = configInterfaceName(sensorTypes[fanType]);
// convert to 0 based
size_t index = std::stoul(indexStr) - 1;
@@ -249,7 +248,7 @@
{
// find the base of the configuration to see if indexes
// match
- auto sensorBaseFind = cfgData.find(sensorTypes[fanType]);
+ auto sensorBaseFind = cfgData.find(cfgIntf);
if (sensorBaseFind == cfgData.end())
{
continue;
@@ -364,7 +363,7 @@
}
auto presenceConfig =
- sensorData->find(baseType + std::string(".Presence"));
+ sensorData->find(cfgIntf + std::string(".Presence"));
std::unique_ptr<PresenceSensor> presenceSensor(nullptr);
@@ -410,7 +409,7 @@
std::make_pair(defaultMinReading, defaultMaxReading);
auto connector =
- sensorData->find(baseType + std::string(".Connector"));
+ sensorData->find(cfgIntf + std::string(".Connector"));
std::optional<std::string> led;
std::string pwmName;