pseq: Add Services parameter to getGPIOValues()
Add a Services parameter to the PowerSequencerDevice::getGPIOValues()
method in the phosphor-power-sequencer application.
The Services object implements reading GPIO values in the standard way
using the libgpiod interface.
Change-Id: Ia6d1f1a0919aa6f45405cbe8375f8cc37800b002
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/phosphor-power-sequencer/src/power_sequencer_device.hpp b/phosphor-power-sequencer/src/power_sequencer_device.hpp
index 7a8c1b3..4b3ada6 100644
--- a/phosphor-power-sequencer/src/power_sequencer_device.hpp
+++ b/phosphor-power-sequencer/src/power_sequencer_device.hpp
@@ -70,9 +70,10 @@
* Throws an exception if the values could not be read or the device does
* not support GPIO values.
*
+ * @param services System services like hardware presence and the journal
* @return GPIO values
*/
- virtual std::vector<int> getGPIOValues() = 0;
+ virtual std::vector<int> getGPIOValues(Services& services) = 0;
/**
* Returns the value of the PMBus STATUS_WORD command for the specified
diff --git a/phosphor-power-sequencer/src/standard_device.cpp b/phosphor-power-sequencer/src/standard_device.cpp
index cc999c5..b49b67f 100644
--- a/phosphor-power-sequencer/src/standard_device.cpp
+++ b/phosphor-power-sequencer/src/standard_device.cpp
@@ -37,7 +37,7 @@
// Get all GPIO values (if possible) from device. They may be slow to
// obtain, so obtain them once and then pass values to each Rail object.
- std::vector<int> gpioValues = getGPIOValuesIfPossible();
+ std::vector<int> gpioValues = getGPIOValuesIfPossible(services);
// Loop through all the rails checking if any detected a pgood fault.
// The rails are in power-on-sequence order.
@@ -76,12 +76,12 @@
return error;
}
-std::vector<int> StandardDevice::getGPIOValuesIfPossible()
+std::vector<int> StandardDevice::getGPIOValuesIfPossible(Services& services)
{
std::vector<int> values{};
try
{
- values = getGPIOValues();
+ values = getGPIOValues(services);
}
catch (...)
{}
diff --git a/phosphor-power-sequencer/src/standard_device.hpp b/phosphor-power-sequencer/src/standard_device.hpp
index 3dbba2f..af7e29e 100644
--- a/phosphor-power-sequencer/src/standard_device.hpp
+++ b/phosphor-power-sequencer/src/standard_device.hpp
@@ -104,9 +104,10 @@
* If the device does not support reading GPIO values or an error occurs, an
* empty vector is returned.
*
+ * @param services System services like hardware presence and the journal
* @return GPIO values, or empty vector if values could not be read
*/
- virtual std::vector<int> getGPIOValuesIfPossible();
+ virtual std::vector<int> getGPIOValuesIfPossible(Services& services);
/**
* Store pgood fault debug data in the specified additional data map.
diff --git a/phosphor-power-sequencer/test/mock_device.hpp b/phosphor-power-sequencer/test/mock_device.hpp
index 431e379..7140f65 100644
--- a/phosphor-power-sequencer/test/mock_device.hpp
+++ b/phosphor-power-sequencer/test/mock_device.hpp
@@ -41,7 +41,8 @@
MOCK_METHOD(const std::string&, getName, (), (const, override));
MOCK_METHOD(const std::vector<std::unique_ptr<Rail>>&, getRails, (),
(const, override));
- MOCK_METHOD(std::vector<int>, getGPIOValues, (), (override));
+ MOCK_METHOD(std::vector<int>, getGPIOValues, (Services & services),
+ (override));
MOCK_METHOD(uint16_t, getStatusWord, (uint8_t page), (override));
MOCK_METHOD(uint8_t, getStatusVout, (uint8_t page), (override));
MOCK_METHOD(double, getReadVout, (uint8_t page), (override));
diff --git a/phosphor-power-sequencer/test/standard_device_tests.cpp b/phosphor-power-sequencer/test/standard_device_tests.cpp
index 977ad1a..2eb3a42 100644
--- a/phosphor-power-sequencer/test/standard_device_tests.cpp
+++ b/phosphor-power-sequencer/test/standard_device_tests.cpp
@@ -16,6 +16,7 @@
#include "mock_services.hpp"
#include "rail.hpp"
+#include "services.hpp"
#include "standard_device.hpp"
#include <cstdint>
@@ -65,7 +66,8 @@
{}
// Mock pure virtual methods
- MOCK_METHOD(std::vector<int>, getGPIOValues, (), (override));
+ MOCK_METHOD(std::vector<int>, getGPIOValues, (Services & services),
+ (override));
MOCK_METHOD(uint16_t, getStatusWord, (uint8_t page), (override));
MOCK_METHOD(uint8_t, getStatusVout, (uint8_t page), (override));
MOCK_METHOD(double, getReadVout, (uint8_t page), (override));