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/power-supply/power_supply.cpp b/power-supply/power_supply.cpp
index 0a5c9cc..62067ef 100644
--- a/power-supply/power_supply.cpp
+++ b/power-supply/power_supply.cpp
@@ -121,7 +121,6 @@
void PowerSupply::getAccessType()
{
- using namespace phosphor::pmbus;
using namespace phosphor::power::util;
fruJson = loadJSONFromFile(PSU_JSON_PATH);
if (fruJson == nullptr)
@@ -129,29 +128,7 @@
log<level::ERR>("InternalFailure when parsing the JSON file");
return;
}
-
- auto type = fruJson.at("inventoryPMBusAccessType");
-
- if (type == "Hwmon")
- {
- inventoryPMBusAccessType = Type::Hwmon;
- }
- else if (type == "DeviceDebug")
- {
- inventoryPMBusAccessType = Type::DeviceDebug;
- }
- else if (type == "Debug")
- {
- inventoryPMBusAccessType = Type::Debug;
- }
- else if (type == "HwmonDeviceDebug")
- {
- inventoryPMBusAccessType = Type::HwmonDeviceDebug;
- }
- else
- {
- inventoryPMBusAccessType = Type::Base;
- }
+ inventoryPMBusAccessType = getPMBusAccessType(fruJson);
}
void PowerSupply::captureCmd(util::NamesValues& nv, const std::string& cmd,