psu-ng: Make statusWord a member variable with accessor
The STATUS_WORD value read should be included in the PEL additional data
when an error is logged. Make it a member variable of the PowerSupply
class and provide an accessor function.
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: Ief8b47e659a2fa6836d467339f2c0dd139c02e73
diff --git a/phosphor-power-supply/power_supply.cpp b/phosphor-power-supply/power_supply.cpp
index 7fffd70..97acd6d 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -39,7 +39,7 @@
{
try
{
- auto statusWord{pmbusIntf->read(STATUS_WORD, Type::Debug)};
+ statusWord = pmbusIntf->read(STATUS_WORD, Type::Debug);
if (statusWord)
{
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index ecf4d82..c94871f 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -136,6 +136,14 @@
}
/**
+ * @brief Returns the last read value from STATUS_WORD.
+ */
+ uint64_t getStatusWord() const
+ {
+ return statusWord;
+ }
+
+ /**
* @brief Returns true if a fault was found.
*/
bool isFaulted() const
@@ -176,6 +184,9 @@
/** @brief systemd bus member */
sdbusplus::bus::bus& bus;
+ /** @brief Will be updated to the latest/lastvalue read from STATUS_WORD. */
+ uint64_t statusWord = 0;
+
/** @brief True if a fault has already been found and not cleared */
bool faultFound = false;