regulators: Modify close() to use services

Modify the Device::close() method in the Device class to have a new
first parameter: Services& services.

Modify Device::close() to log messages using the new Journal
interface.

Modify the Chassis::closeDevices() method in the Chassis class to
have a new first parameter: Services& services.

Modify Chassis::closeDevices() to log messages using the new
Journal interface.

Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: I2a07417d6f7470685f2c27c878ef7936e9f1aa8a
diff --git a/phosphor-regulators/src/chassis.cpp b/phosphor-regulators/src/chassis.cpp
index eb7f496..85e8275 100644
--- a/phosphor-regulators/src/chassis.cpp
+++ b/phosphor-regulators/src/chassis.cpp
@@ -16,7 +16,6 @@
 
 #include "chassis.hpp"
 
-#include "journal.hpp"
 #include "system.hpp"
 
 namespace phosphor::power::regulators
@@ -31,15 +30,16 @@
     }
 }
 
-void Chassis::closeDevices()
+void Chassis::closeDevices(Services& services)
 {
     // Log debug message in journal
-    journal::logDebug("Closing devices in chassis " + std::to_string(number));
+    services.getJournal().logDebug("Closing devices in chassis " +
+                                   std::to_string(number));
 
     // Close devices
     for (std::unique_ptr<Device>& device : devices)
     {
-        device->close();
+        device->close(services);
     }
 }
 
diff --git a/phosphor-regulators/src/chassis.hpp b/phosphor-regulators/src/chassis.hpp
index b61b79c..86d99f8 100644
--- a/phosphor-regulators/src/chassis.hpp
+++ b/phosphor-regulators/src/chassis.hpp
@@ -87,8 +87,10 @@
 
     /**
      * Close the devices within this chassis, if any.
+     *
+     * @param services system services like error logging and the journal
      */
-    void closeDevices();
+    void closeDevices(Services& services);
 
     /**
      * Configure the devices within this chassis, if any.
diff --git a/phosphor-regulators/src/device.cpp b/phosphor-regulators/src/device.cpp
index df73d1a..062ff27 100644
--- a/phosphor-regulators/src/device.cpp
+++ b/phosphor-regulators/src/device.cpp
@@ -18,7 +18,6 @@
 
 #include "chassis.hpp"
 #include "exception_utils.hpp"
-#include "journal.hpp"
 #include "system.hpp"
 
 #include <exception>
@@ -38,7 +37,7 @@
     }
 }
 
-void Device::close()
+void Device::close(Services& services)
 {
     try
     {
@@ -51,8 +50,8 @@
     catch (const std::exception& e)
     {
         // Log error messages in journal
-        exception_utils::log(e);
-        journal::logErr("Unable to close device " + id);
+        services.getJournal().logError(exception_utils::getMessages(e));
+        services.getJournal().logError("Unable to close device " + id);
 
         // TODO: Create error log entry
     }
diff --git a/phosphor-regulators/src/device.hpp b/phosphor-regulators/src/device.hpp
index d0466eb..ccdb30a 100644
--- a/phosphor-regulators/src/device.hpp
+++ b/phosphor-regulators/src/device.hpp
@@ -91,8 +91,10 @@
      *
      * Closes any interfaces that are open to this device.  Releases any other
      * operating system resources associated with this device.
+     *
+     * @param services system services like error logging and the journal
      */
-    void close();
+    void close(Services& services);
 
     /**
      * Configure this device.
diff --git a/phosphor-regulators/src/manager.cpp b/phosphor-regulators/src/manager.cpp
index bb0e3a8..1bffe24 100644
--- a/phosphor-regulators/src/manager.cpp
+++ b/phosphor-regulators/src/manager.cpp
@@ -123,7 +123,7 @@
             // normally disabled because the system is being powered off.  The
             // devices should be closed in case hardware is removed or replaced
             // while the system is at standby.
-            system->closeDevices();
+            system->closeDevices(services);
         }
     }
 }
diff --git a/phosphor-regulators/src/system.cpp b/phosphor-regulators/src/system.cpp
index 8f3412c..a032935 100644
--- a/phosphor-regulators/src/system.cpp
+++ b/phosphor-regulators/src/system.cpp
@@ -34,12 +34,12 @@
     }
 }
 
-void System::closeDevices()
+void System::closeDevices(Services& services)
 {
     // Close devices in each chassis
     for (std::unique_ptr<Chassis>& oneChassis : chassis)
     {
-        oneChassis->closeDevices();
+        oneChassis->closeDevices(services);
     }
 }
 
diff --git a/phosphor-regulators/src/system.hpp b/phosphor-regulators/src/system.hpp
index 16c4ee0..2ef14b8 100644
--- a/phosphor-regulators/src/system.hpp
+++ b/phosphor-regulators/src/system.hpp
@@ -62,8 +62,10 @@
 
     /**
      * Close the regulator devices in the system.
+     *
+     * @param services system services like error logging and the journal
      */
-    void closeDevices();
+    void closeDevices(Services& services);
 
     /**
      * Configure the regulator devices in the system.