regulators: Add Services& services to classes

Modify the configure() method in the System, Chassis, Device, and Rail
classes to have a new first parameter: Services& services.

Fix mock_services.hpp bug.

Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: I6ef41de65d2c5b68c55edb42189ba9c0f2e436ed
diff --git a/phosphor-regulators/src/chassis.cpp b/phosphor-regulators/src/chassis.cpp
index 29ebb79..ebe446c 100644
--- a/phosphor-regulators/src/chassis.cpp
+++ b/phosphor-regulators/src/chassis.cpp
@@ -43,7 +43,7 @@
     }
 }
 
-void Chassis::configure(System& system)
+void Chassis::configure(Services& services, System& system)
 {
     // Log info message in journal; important for verifying success of boot
     journal::logInfo("Configuring chassis " + std::to_string(number));
@@ -51,7 +51,7 @@
     // Configure devices
     for (std::unique_ptr<Device>& device : devices)
     {
-        device->configure(system, *this);
+        device->configure(services, system, *this);
     }
 }
 
diff --git a/phosphor-regulators/src/chassis.hpp b/phosphor-regulators/src/chassis.hpp
index 4423926..3addd5e 100644
--- a/phosphor-regulators/src/chassis.hpp
+++ b/phosphor-regulators/src/chassis.hpp
@@ -17,6 +17,7 @@
 
 #include "device.hpp"
 #include "id_map.hpp"
+#include "services.hpp"
 
 #include <memory>
 #include <stdexcept>
@@ -95,9 +96,10 @@
      * This method should be called during the boot before regulators are
      * enabled.
      *
+     * @param services system services like error logging and the journal
      * @param system system that contains this chassis
      */
-    void configure(System& system);
+    void configure(Services& services, System& system);
 
     /**
      * Returns the devices within this chassis, if any.
diff --git a/phosphor-regulators/src/configuration.cpp b/phosphor-regulators/src/configuration.cpp
index 99245ca..8edc36c 100644
--- a/phosphor-regulators/src/configuration.cpp
+++ b/phosphor-regulators/src/configuration.cpp
@@ -30,19 +30,21 @@
 namespace phosphor::power::regulators
 {
 
-void Configuration::execute(System& system, Chassis& chassis, Device& device)
+void Configuration::execute(Services& services, System& system,
+                            Chassis& chassis, Device& device)
 {
-    execute(system, chassis, device, device.getID());
+    execute(services, system, chassis, device, device.getID());
 }
 
-void Configuration::execute(System& system, Chassis& chassis, Device& device,
-                            Rail& rail)
+void Configuration::execute(Services& services, System& system,
+                            Chassis& chassis, Device& device, Rail& rail)
 {
-    execute(system, chassis, device, rail.getID());
+    execute(services, system, chassis, device, rail.getID());
 }
 
-void Configuration::execute(System& system, Chassis& /*chassis*/,
-                            Device& device, const std::string& deviceOrRailID)
+void Configuration::execute(Services& /*services*/, System& system,
+                            Chassis& /*chassis*/, Device& device,
+                            const std::string& deviceOrRailID)
 {
     try
     {
diff --git a/phosphor-regulators/src/configuration.hpp b/phosphor-regulators/src/configuration.hpp
index 3534419..f0dd766 100644
--- a/phosphor-regulators/src/configuration.hpp
+++ b/phosphor-regulators/src/configuration.hpp
@@ -16,6 +16,7 @@
 #pragma once
 
 #include "action.hpp"
+#include "services.hpp"
 
 #include <memory>
 #include <optional>
@@ -82,11 +83,13 @@
      * This method should be called during the boot before regulators are
      * enabled.
      *
+     * @param services system services like error logging and the journal
      * @param system system that contains the chassis
      * @param chassis chassis that contains the device
      * @param device device to configure
      */
-    void execute(System& system, Chassis& chassis, Device& device);
+    void execute(Services& services, System& system, Chassis& chassis,
+                 Device& device);
 
     /**
      * Executes the actions to configure the specified rail.
@@ -94,12 +97,14 @@
      * This method should be called during the boot before regulators are
      * enabled.
      *
+     * @param services system services like error logging and the journal
      * @param system system that contains the chassis
      * @param chassis chassis that contains the device
      * @param device device that contains the rail
      * @param rail rail to configure
      */
-    void execute(System& system, Chassis& chassis, Device& device, Rail& rail);
+    void execute(Services& services, System& system, Chassis& chassis,
+                 Device& device, Rail& rail);
 
     /**
      * Returns the actions that configure the device/rail.
@@ -125,13 +130,14 @@
     /**
      * Executes the actions to configure a device or rail.
      *
+     * @param services system services like error logging and the journal
      * @param system system that contains the chassis
      * @param chassis chassis that contains the device
      * @param device device to configure or that contains rail to configure
      * @param deviceOrRailID ID of the device or rail to configure
      */
-    void execute(System& system, Chassis& chassis, Device& device,
-                 const std::string& deviceOrRailID);
+    void execute(Services& services, System& system, Chassis& chassis,
+                 Device& device, const std::string& deviceOrRailID);
 
     /**
      * Optional output voltage value.
diff --git a/phosphor-regulators/src/device.cpp b/phosphor-regulators/src/device.cpp
index fd07d71..f085afe 100644
--- a/phosphor-regulators/src/device.cpp
+++ b/phosphor-regulators/src/device.cpp
@@ -58,18 +58,18 @@
     }
 }
 
-void Device::configure(System& system, Chassis& chassis)
+void Device::configure(Services& services, System& system, Chassis& chassis)
 {
     // If configuration changes are defined for this device, apply them
     if (configuration)
     {
-        configuration->execute(system, chassis, *this);
+        configuration->execute(services, system, chassis, *this);
     }
 
     // Configure rails
     for (std::unique_ptr<Rail>& rail : rails)
     {
-        rail->configure(system, chassis, *this);
+        rail->configure(services, system, chassis, *this);
     }
 }
 
diff --git a/phosphor-regulators/src/device.hpp b/phosphor-regulators/src/device.hpp
index e18f6fa..cb3a3d9 100644
--- a/phosphor-regulators/src/device.hpp
+++ b/phosphor-regulators/src/device.hpp
@@ -20,6 +20,7 @@
 #include "id_map.hpp"
 #include "presence_detection.hpp"
 #include "rail.hpp"
+#include "services.hpp"
 
 #include <memory>
 #include <string>
@@ -104,10 +105,11 @@
      * This method should be called during the boot before regulators are
      * enabled.
      *
+     * @param services system services like error logging and the journal
      * @param system system that contains the chassis
      * @param chassis chassis that contains this device
      */
-    void configure(System& system, Chassis& chassis);
+    void configure(Services& services, System& system, Chassis& chassis);
 
     /**
      * Returns the configuration changes to apply to this device, if any.
diff --git a/phosphor-regulators/src/manager.cpp b/phosphor-regulators/src/manager.cpp
index fd8dd01..bb0e3a8 100644
--- a/phosphor-regulators/src/manager.cpp
+++ b/phosphor-regulators/src/manager.cpp
@@ -84,7 +84,7 @@
     if (system)
     {
         // Configure the regulator devices in the system
-        system->configure();
+        system->configure(services);
     }
     else
     {
diff --git a/phosphor-regulators/src/rail.cpp b/phosphor-regulators/src/rail.cpp
index 7d90e77..3739ef0 100644
--- a/phosphor-regulators/src/rail.cpp
+++ b/phosphor-regulators/src/rail.cpp
@@ -23,12 +23,13 @@
 namespace phosphor::power::regulators
 {
 
-void Rail::configure(System& system, Chassis& chassis, Device& device)
+void Rail::configure(Services& services, System& system, Chassis& chassis,
+                     Device& device)
 {
     // If configuration changes are defined for this rail, apply them
     if (configuration)
     {
-        configuration->execute(system, chassis, device, *this);
+        configuration->execute(services, system, chassis, device, *this);
     }
 }
 
diff --git a/phosphor-regulators/src/rail.hpp b/phosphor-regulators/src/rail.hpp
index 8340d07..9caafbe 100644
--- a/phosphor-regulators/src/rail.hpp
+++ b/phosphor-regulators/src/rail.hpp
@@ -17,6 +17,7 @@
 
 #include "configuration.hpp"
 #include "sensor_monitoring.hpp"
+#include "services.hpp"
 
 #include <memory>
 #include <string>
@@ -74,11 +75,13 @@
      * This method should be called during the boot before regulators are
      * enabled.
      *
+     * @param services system services like error logging and the journal
      * @param system system that contains the chassis
      * @param chassis chassis that contains the device
      * @param device device that contains this rail
      */
-    void configure(System& system, Chassis& chassis, Device& device);
+    void configure(Services& services, System& system, Chassis& chassis,
+                   Device& device);
 
     /**
      * Returns the configuration changes to apply to this rail, if any.
diff --git a/phosphor-regulators/src/system.cpp b/phosphor-regulators/src/system.cpp
index d3b599a..d6be768 100644
--- a/phosphor-regulators/src/system.cpp
+++ b/phosphor-regulators/src/system.cpp
@@ -43,12 +43,12 @@
     }
 }
 
-void System::configure()
+void System::configure(Services& services)
 {
     // Configure devices in each chassis
     for (std::unique_ptr<Chassis>& oneChassis : chassis)
     {
-        oneChassis->configure(*this);
+        oneChassis->configure(services, *this);
     }
 }
 
diff --git a/phosphor-regulators/src/system.hpp b/phosphor-regulators/src/system.hpp
index f678658..3ffeb5b 100644
--- a/phosphor-regulators/src/system.hpp
+++ b/phosphor-regulators/src/system.hpp
@@ -18,6 +18,7 @@
 #include "chassis.hpp"
 #include "id_map.hpp"
 #include "rule.hpp"
+#include "services.hpp"
 
 #include <memory>
 #include <utility>
@@ -69,8 +70,10 @@
      *
      * This method should be called during the boot before regulators are
      * enabled.
+     *
+     * @param services system services like error logging and the journal
      */
-    void configure();
+    void configure(Services& services);
 
     /**
      * Returns the chassis in the system.