regulators: Remove Services& from Sensors methods

Remove the Services& parameter from the Sensors methods.  This parameter
introduces a circular include dependency, and the parameter was only
being lightly used in two Sensors methods.

Tested:
* Verified that all DBusSensors methods work as expected.

Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I3b2c3ec0bec7ea51b24100531f3314e9f87cebee
diff --git a/phosphor-regulators/src/dbus_sensors.cpp b/phosphor-regulators/src/dbus_sensors.cpp
index eee7bc2..c9b4c2b 100644
--- a/phosphor-regulators/src/dbus_sensors.cpp
+++ b/phosphor-regulators/src/dbus_sensors.cpp
@@ -21,13 +21,13 @@
 namespace phosphor::power::regulators
 {
 
-void DBusSensors::enable(Services& /*services*/)
+void DBusSensors::enable()
 {
     // Currently nothing to do here.  The next monitoring cycle will set the
     // values of all sensors, and that will set them to the enabled state.
 }
 
-void DBusSensors::endCycle(Services& services)
+void DBusSensors::endCycle()
 {
     // Delete any sensors that were not updated during this monitoring cycle.
     // This can happen if the hardware device producing the sensors was removed
@@ -43,13 +43,12 @@
         // Check if last update time for sensor is before cycle start time
         if (sensor->getLastUpdateTime() < cycleStartTime)
         {
-            services.getJournal().logDebug("Deleted sensor " + sensorName);
             sensors.erase(sensorName);
         }
     }
 }
 
-void DBusSensors::endRail(bool errorOccurred, Services& /*services*/)
+void DBusSensors::endRail(bool errorOccurred)
 {
     // If an error occurred, set all sensors for current rail to the error state
     if (errorOccurred)
@@ -69,7 +68,7 @@
     chassisInventoryPath.clear();
 }
 
-void DBusSensors::disable(Services& /*services*/)
+void DBusSensors::disable()
 {
     // Disable all sensors
     for (auto& [sensorName, sensor] : sensors)
@@ -78,7 +77,7 @@
     }
 }
 
-void DBusSensors::setValue(SensorType type, double value, Services& services)
+void DBusSensors::setValue(SensorType type, double value)
 {
     // Build unique sensor name based on rail and sensor type
     std::string sensorName{rail + '_' + sensors::toString(type)};
@@ -97,11 +96,10 @@
                                                    rail, deviceInventoryPath,
                                                    chassisInventoryPath);
         sensors.emplace(sensorName, std::move(sensor));
-        services.getJournal().logDebug("Created sensor " + sensorName);
     }
 }
 
-void DBusSensors::startCycle(Services& /*services*/)
+void DBusSensors::startCycle()
 {
     // Store the time when this monitoring cycle started.  This is used to
     // detect sensors that were not updated during this cycle.
@@ -110,8 +108,7 @@
 
 void DBusSensors::startRail(const std::string& rail,
                             const std::string& deviceInventoryPath,
-                            const std::string& chassisInventoryPath,
-                            Services& /*services*/)
+                            const std::string& chassisInventoryPath)
 {
     // Store current rail information; used later by setValue() and endRail()
     this->rail = rail;
diff --git a/phosphor-regulators/src/dbus_sensors.hpp b/phosphor-regulators/src/dbus_sensors.hpp
index 4ffa70b..229ae9f 100644
--- a/phosphor-regulators/src/dbus_sensors.hpp
+++ b/phosphor-regulators/src/dbus_sensors.hpp
@@ -17,7 +17,6 @@
 
 #include "dbus_sensor.hpp"
 #include "sensors.hpp"
-#include "services.hpp"
 
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server/manager.hpp>
@@ -57,29 +56,27 @@
     }
 
     /** @copydoc Sensors::enable() */
-    virtual void enable(Services& services) override;
+    virtual void enable() override;
 
     /** @copydoc Sensors::endCycle() */
-    virtual void endCycle(Services& services) override;
+    virtual void endCycle() override;
 
     /** @copydoc Sensors::endRail() */
-    virtual void endRail(bool errorOccurred, Services& services) override;
+    virtual void endRail(bool errorOccurred) override;
 
     /** @copydoc Sensors::disable() */
-    virtual void disable(Services& services) override;
+    virtual void disable() override;
 
     /** @copydoc Sensors::setValue() */
-    virtual void setValue(SensorType type, double value,
-                          Services& services) override;
+    virtual void setValue(SensorType type, double value) override;
 
     /** @copydoc Sensors::startCycle() */
-    virtual void startCycle(Services& services) override;
+    virtual void startCycle() override;
 
     /** @copydoc Sensors::startRail() */
     virtual void startRail(const std::string& rail,
                            const std::string& deviceInventoryPath,
-                           const std::string& chassisInventoryPath,
-                           Services& services) override;
+                           const std::string& chassisInventoryPath) override;
 
   private:
     /**
diff --git a/phosphor-regulators/src/sensors.hpp b/phosphor-regulators/src/sensors.hpp
index 1fe0daf..32c023f 100644
--- a/phosphor-regulators/src/sensors.hpp
+++ b/phosphor-regulators/src/sensors.hpp
@@ -15,8 +15,6 @@
  */
 #pragma once
 
-#include "services.hpp"
-
 #include <string>
 
 namespace phosphor::power::regulators
@@ -177,18 +175,14 @@
      * While the service is enabled, the sensors that it provides will be in an
      * active state.  This indicates that their value is being updated
      * periodically.
-     *
-     * @param services system services
      */
-    virtual void enable(Services& services) = 0;
+    virtual void enable() = 0;
 
     /**
      * Notify the sensors service that the current sensor monitoring cycle has
      * ended.
-     *
-     * @param services system services
      */
-    virtual void endCycle(Services& services) = 0;
+    virtual void endCycle() = 0;
 
     /**
      * Notify the sensors service that sensor monitoring has ended for the
@@ -196,19 +190,16 @@
      *
      * @param errorOccurred specifies whether an error occurred while trying to
      *                      read all the sensors for the current rail
-     * @param services system services
      */
-    virtual void endRail(bool errorOccurred, Services& services) = 0;
+    virtual void endRail(bool errorOccurred) = 0;
 
     /**
      * Disable the sensors service.
      *
      * While the service is disabled, the sensors that it provides will be in an
      * inactive state.  This indicates that their value is not being updated.
-     *
-     * @param services system services
      */
-    virtual void disable(Services& services) = 0;
+    virtual void disable() = 0;
 
     /**
      * Sets the value of one sensor for the current voltage rail.
@@ -217,17 +208,13 @@
      *
      * @param type sensor type
      * @param value sensor value
-     * @param services system services
      */
-    virtual void setValue(SensorType type, double value,
-                          Services& services) = 0;
+    virtual void setValue(SensorType type, double value) = 0;
 
     /**
      * Notify the sensors service that a sensor monitoring cycle is starting.
-     *
-     * @param services system services
      */
-    virtual void startCycle(Services& services) = 0;
+    virtual void startCycle() = 0;
 
     /**
      * Notify the sensors service that sensor monitoring is starting for the
@@ -240,12 +227,10 @@
      *                            device that produces the rail
      * @param chassisInventoryPath D-Bus inventory path of the chassis that
      *                             contains the voltage regulator device
-     * @param services system services
      */
     virtual void startRail(const std::string& rail,
                            const std::string& deviceInventoryPath,
-                           const std::string& chassisInventoryPath,
-                           Services& services) = 0;
+                           const std::string& chassisInventoryPath) = 0;
 };
 
 } // namespace phosphor::power::regulators
diff --git a/phosphor-regulators/test/mock_sensors.hpp b/phosphor-regulators/test/mock_sensors.hpp
index 0973d7c..b649e9c 100644
--- a/phosphor-regulators/test/mock_sensors.hpp
+++ b/phosphor-regulators/test/mock_sensors.hpp
@@ -16,7 +16,6 @@
 #pragma once
 
 #include "sensors.hpp"
-#include "services.hpp"
 
 #include <string>
 
@@ -41,25 +40,22 @@
     MockSensors& operator=(MockSensors&&) = delete;
     virtual ~MockSensors() = default;
 
-    MOCK_METHOD(void, enable, (Services & services), (override));
+    MOCK_METHOD(void, enable, (), (override));
 
-    MOCK_METHOD(void, endCycle, (Services & services), (override));
+    MOCK_METHOD(void, endCycle, (), (override));
 
-    MOCK_METHOD(void, endRail, (bool errorOccurred, Services& services),
-                (override));
+    MOCK_METHOD(void, endRail, (bool errorOccurred), (override));
 
-    MOCK_METHOD(void, disable, (Services & services), (override));
+    MOCK_METHOD(void, disable, (), (override));
 
-    MOCK_METHOD(void, setValue,
-                (SensorType type, double value, Services& services),
-                (override));
+    MOCK_METHOD(void, setValue, (SensorType type, double value), (override));
 
-    MOCK_METHOD(void, startCycle, (Services & services), (override));
+    MOCK_METHOD(void, startCycle, (), (override));
 
     MOCK_METHOD(void, startRail,
                 (const std::string& rail,
                  const std::string& deviceInventoryPath,
-                 const std::string& chassisInventoryPath, Services& services),
+                 const std::string& chassisInventoryPath),
                 (override));
 };