regulators: Add closeDevices() to Chassis class
Add a closeDevices() method to the Chassis class. This will close all
devices within the chassis. The devices should be closed when monitoring
is disabled and the system is being powered off.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I713bf470392aa49632a34fa42bf849fa2f1c4c01
diff --git a/phosphor-regulators/src/chassis.cpp b/phosphor-regulators/src/chassis.cpp
index 3390ec5..a0d0c2b 100644
--- a/phosphor-regulators/src/chassis.cpp
+++ b/phosphor-regulators/src/chassis.cpp
@@ -31,6 +31,18 @@
}
}
+void Chassis::closeDevices()
+{
+ // Log debug message in journal
+ journal::logDebug("Closing devices in chassis " + std::to_string(number));
+
+ // Close devices
+ for (std::unique_ptr<Device>& device : devices)
+ {
+ device->close();
+ }
+}
+
void Chassis::configure(System& system)
{
// Log info message in journal; important for verifying success of boot
diff --git a/phosphor-regulators/src/chassis.hpp b/phosphor-regulators/src/chassis.hpp
index 354da30..3fd3792 100644
--- a/phosphor-regulators/src/chassis.hpp
+++ b/phosphor-regulators/src/chassis.hpp
@@ -85,6 +85,11 @@
void addToIDMap(IDMap& idMap);
/**
+ * Close the devices within this chassis, if any.
+ */
+ void closeDevices();
+
+ /**
* Configure the devices within this chassis, if any.
*
* This method should be called during the boot before regulators are