From 8ee0eb0cdbb7c3570c4a5ae65a44b22edb3b70a6 Mon Sep 17 00:00:00 2001
From: wangjue <jue.wang2@luxshare-ict.com>
Date: Mon, 11 Nov 2024 15:25:16 +0800
Subject: [PATCH] Remove updateDIMMLedState function as dimm presence state
 will be set by bios

Signed-off-by: wangjue <jue.wang2@luxshare-ict.com>
---
 src/DIMMTempSensor.cpp     | 25 ++-----------------------
 src/DIMMTempSensor.hpp     |  3 ---
 src/DIMMTempSensorMain.cpp |  1 -
 3 files changed, 2 insertions(+), 27 deletions(-)

diff --git a/src/DIMMTempSensor.cpp b/src/DIMMTempSensor.cpp
index 94843d2..1399995 100644
--- a/src/DIMMTempSensor.cpp
+++ b/src/DIMMTempSensor.cpp
@@ -60,7 +60,7 @@ DIMMTempSensor::DIMMTempSensor(
            std::move(thresholdData), sensorConfiguration, "", false, false,
            maxReading, minReading, conn, readState),
     sensorPollMs(static_cast<unsigned int>(pollRate * 1000)), peciBus(peciBus),
-    peciAddr(peciAddr), dimmRank(rank), calibOffset(calibOffset), dimmLEDState("OFF"),
+    peciAddr(peciAddr), dimmRank(rank), calibOffset(calibOffset),
     objectServer(objectServer), waitTimer(io)
 {
     std::string interfacePath = "/xyz/openbmc_project/sensors/" + sensorType +
@@ -72,6 +72,7 @@ DIMMTempSensor::DIMMTempSensor(
     dimmLEDInterface = objectServer.add_interface(
         interfacePath, "xyz.openbmc_project.Sensor.dimmLED");
 
+    std::string dimmLEDState = "OFF";
     dimmLEDInterface->register_property(
                 "LEDState", dimmLEDState, [this](const std::string& newValue, std::string& oldValue) {
                     oldValue = newValue; return true;
@@ -192,40 +193,18 @@ void DIMMTempSensor::read()
                               << temp << "\n";
                 }
                 v += calibOffset;
-
-
-                updateDIMMLedState(dimmLEDInterface, dimmLEDState, "ON", "LEDState");
                 updateValue(v);
             }
             else
             {
                 std::cerr << "Fail to read DIMM tempture.\n";
-                updateDIMMLedState(dimmLEDInterface, dimmLEDState, "OFF", "LEDState");
                 incrementError();
             }
         }
         else
         {
             updateValue(std::numeric_limits<double>::quiet_NaN());
-            updateDIMMLedState(dimmLEDInterface, dimmLEDState, "OFF", "LEDState");
         }
         read();
     });
 }
-
-void DIMMTempSensor::updateDIMMLedState(std::shared_ptr<sdbusplus::asio::dbus_interface>& interface,
-        std::string& oldState, const std::string& newState, const char* dbusPropertyName)
-{
-    if(oldState == newState)
-        return;
-    oldState = newState;
-
-    if (interface &&
-        !(interface->set_property(dbusPropertyName, newState)))
-    {
-        std::cerr << "error setting property " << dbusPropertyName
-                    << " to " << newState << "\n";
-    }
-
-    return;
-}
diff --git a/src/DIMMTempSensor.hpp b/src/DIMMTempSensor.hpp
index 9aea017..1f7d8d3 100644
--- a/src/DIMMTempSensor.hpp
+++ b/src/DIMMTempSensor.hpp
@@ -33,13 +33,10 @@ struct DIMMTempSensor : public Sensor
     uint8_t peciAddr;
     uint8_t dimmRank;
     double calibOffset;
-    std::string dimmLEDState;
 
   private:
     int getDIMMRegsInfoWord(double* ps64data);
     int getDIMMRegsTemp(double* ps64data);
-    void updateDIMMLedState(std::shared_ptr<sdbusplus::asio::dbus_interface>& interface,
-        std::string& oldState, const std::string& newState, const char* dbusPropertyName);
    // int getDIMMRegsPower(double* ps64data);
     sdbusplus::asio::object_server& objectServer;
     boost::asio::steady_timer waitTimer;
diff --git a/src/DIMMTempSensorMain.cpp b/src/DIMMTempSensorMain.cpp
index 5c3573c..042659f 100644
--- a/src/DIMMTempSensorMain.cpp
+++ b/src/DIMMTempSensorMain.cpp
@@ -87,7 +87,6 @@ void createSensors(
                 uint8_t peciBus = loadVariant<uint8_t>(entry.second, "Bus");
                 uint8_t peciAddr = loadVariant<uint8_t>(entry.second, "Address");
                 uint8_t dimmRank = loadVariant<uint8_t>(entry.second, "Rank");
-                //std::string LEDState = loadVariant<std::string>(entry.second, "LEDState");
 
                 /* calibration offset */
                 auto findCalibOffset = entry.second.find("Offset");
-- 
2.34.1

