psu-ng: Dynamically assign the device driver name
Replaced hardcoded device driver name with a method to build the device
driver name dynamically and assign it to a private data member.
The dynamically built device driver name used during bind/unbind.
Tested the changes in simulation and actual system, compared journalctl
entries of phosphor-psu-monitor with modified phosphor-psu-monitor. The
following test were conducted and verified same journal output:
- Verified driver name assigned correcty to PSU
- Good Machine Path
- Removed Power Supply
- Inserted Power Supply
- Missing Power Supply
Change-Id: Ic376d4ff058e9a2df1887468932faaa28d998960
Signed-off-by: Faisal Awada <faisal@us.ibm.com>
diff --git a/phosphor-power-supply/power_supply.cpp b/phosphor-power-supply/power_supply.cpp
index 3fd72e8..a6e4fae 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -38,7 +38,7 @@
std::function<bool()>&& callback) :
bus(bus),
inventoryPath(invpath), bindPath("/sys/bus/i2c/drivers/" + driver),
- isPowerOn(std::move(callback))
+ isPowerOn(std::move(callback)), driverName(driver)
{
if (inventoryPath.empty())
{
@@ -427,7 +427,7 @@
void PowerSupply::determineMFRFault()
{
- if (bindPath.string().find("ibm-cffps") != std::string::npos)
+ if (bindPath.string().find(IBMCFFPS_DD_NAME) != std::string::npos)
{
// IBM MFR_SPECIFIC[4] is PS_Kill fault
if (statusMFR & 0x10)
@@ -555,7 +555,11 @@
if (statusWord)
{
statusInput = pmbusIntf->read(STATUS_INPUT, Type::Debug);
- statusMFR = pmbusIntf->read(STATUS_MFR, Type::Debug);
+ if (bindPath.string().find(IBMCFFPS_DD_NAME) !=
+ std::string::npos)
+ {
+ statusMFR = pmbusIntf->read(STATUS_MFR, Type::Debug);
+ }
statusCML = pmbusIntf->read(STATUS_CML, Type::Debug);
auto status0Vout = pmbusIntf->insertPageNum(STATUS_VOUT, 0);
statusVout = pmbusIntf->read(status0Vout, Type::Debug);
@@ -1025,7 +1029,7 @@
void PowerSupply::setupInputHistory()
{
- if (bindPath.string().find("ibm-cffps") != std::string::npos)
+ if (bindPath.string().find(IBMCFFPS_DD_NAME) != std::string::npos)
{
auto maxPowerOut = getMaxPowerOut();