hwmontempsensor: Convert sensorTypes to I2CDeviceTypeMap
We're going to managing these devices internally soon; rather than
duplicating most of the information in sensorTypes in a separate data
structure we can instead use a single one that can serve both purposes.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: Ic3444c93674fd485debc27207b6f086ff6c222b9
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index 5a773b2..4ee020a 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -14,6 +14,7 @@
// limitations under the License.
*/
+#include <DeviceMgmt.hpp>
#include <HwmonTempSensor.hpp>
#include <Utils.hpp>
#include <boost/algorithm/string/replace.hpp>
@@ -48,11 +49,31 @@
static constexpr double minValueTemperature = -128; // DegreesC
namespace fs = std::filesystem;
-static auto sensorTypes{std::to_array<const char*>(
- {"DPS310", "EMC1412", "EMC1413", "EMC1414", "HDC1080", "JC42",
- "LM75A", "LM95234", "MAX31725", "MAX31730", "MAX6581", "MAX6654",
- "NCT7802", "NCT6779", "SBTSI", "SI7020", "TMP112", "TMP175",
- "TMP421", "TMP441", "TMP75", "W83773G"})};
+
+static const I2CDeviceTypeMap sensorTypes{
+ {"DPS310", I2CDeviceType{"dps310", false}},
+ {"EMC1412", I2CDeviceType{"emc1412", true}},
+ {"EMC1413", I2CDeviceType{"emc1413", true}},
+ {"EMC1414", I2CDeviceType{"emc1414", true}},
+ {"HDC1080", I2CDeviceType{"hdc1080", false}},
+ {"JC42", I2CDeviceType{"jc42", true}},
+ {"LM75A", I2CDeviceType{"lm75a", true}},
+ {"LM95234", I2CDeviceType{"lm95234", true}},
+ {"MAX31725", I2CDeviceType{"max31725", true}},
+ {"MAX31730", I2CDeviceType{"max31730", true}},
+ {"MAX6581", I2CDeviceType{"max6581", true}},
+ {"MAX6654", I2CDeviceType{"max6654", true}},
+ {"NCT6779", I2CDeviceType{"nct6779", true}},
+ {"NCT7802", I2CDeviceType{"nct7802", true}},
+ {"SBTSI", I2CDeviceType{"sbtsi", true}},
+ {"SI7020", I2CDeviceType{"si7020", false}},
+ {"TMP112", I2CDeviceType{"tmp112", true}},
+ {"TMP175", I2CDeviceType{"tmp175", true}},
+ {"TMP421", I2CDeviceType{"tmp421", true}},
+ {"TMP441", I2CDeviceType{"tmp441", true}},
+ {"TMP75", I2CDeviceType{"tmp75", true}},
+ {"W83773G", I2CDeviceType{"w83773g", true}},
+};
static struct SensorParams
getSensorParameters(const std::filesystem::path& path)
@@ -454,8 +475,12 @@
}
}
});
- getter->getConfiguration(
- std::vector<std::string>(sensorTypes.begin(), sensorTypes.end()));
+ std::vector<std::string> types(sensorTypes.size());
+ for (const auto& [type, dt] : sensorTypes)
+ {
+ types.push_back(type);
+ }
+ getter->getConfiguration(types);
}
void interfaceRemoved(