Refactor: move get pmbus access type to utility
The function to get the pmbus access type is common, move it to utility.
Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I26e7da044c88c1efba141349ee4c18b24cdef81f
diff --git a/utility.cpp b/utility.cpp
index 8fe02dc..bd84249 100644
--- a/utility.cpp
+++ b/utility.cpp
@@ -73,6 +73,36 @@
return data;
}
+phosphor::pmbus::Type getPMBusAccessType(const json& json)
+{
+ using namespace phosphor::pmbus;
+ Type type;
+
+ auto typeStr = json.at("inventoryPMBusAccessType");
+
+ if (typeStr == "Hwmon")
+ {
+ type = Type::Hwmon;
+ }
+ else if (typeStr == "DeviceDebug")
+ {
+ type = Type::DeviceDebug;
+ }
+ else if (typeStr == "Debug")
+ {
+ type = Type::Debug;
+ }
+ else if (typeStr == "HwmonDeviceDebug")
+ {
+ type = Type::HwmonDeviceDebug;
+ }
+ else
+ {
+ type = Type::Base;
+ }
+ return type;
+}
+
} // namespace util
} // namespace power
} // namespace phosphor