From 99349f528ef005ed7ecda5d26e247387d28a9c7b Mon Sep 17 00:00:00 2001
From: wangjue <jue.wang2@luxshare-ict.com>
Date: Mon, 9 Sep 2024 13:52:35 +0800
Subject: [PATCH] Modify LED update priority for Changxin's requiremen

Signed-off-by: wangjue <jue.wang2@luxshare-ict.com>
---
 callback-manager/src/callback_manager.cpp | 56 ++++++++---------------
 1 file changed, 19 insertions(+), 37 deletions(-)

diff --git a/callback-manager/src/callback_manager.cpp b/callback-manager/src/callback_manager.cpp
index d6a5dee..4f02986 100644
--- a/callback-manager/src/callback_manager.cpp
+++ b/callback-manager/src/callback_manager.cpp
@@ -24,12 +24,10 @@
 
 #include <variant>
 
-constexpr const char* fatalLedPath =
-    "/xyz/openbmc_project/led/groups/status_critical";
-constexpr const char* criticalLedPath =
-    "/xyz/openbmc_project/led/groups/status_non_critical";
-constexpr const char* warningLedPath =
-    "/xyz/openbmc_project/led/groups/status_degraded";
+constexpr const char* faultLedPath =
+    "/xyz/openbmc_project/led/groups/status_fault";
+constexpr const char* dimmfaultLedPath =
+    "/xyz/openbmc_project/led/groups/dimm_fault";
 constexpr const char* okLedPath = "/xyz/openbmc_project/led/groups/status_ok";
 
 constexpr const char* ledIface = "xyz.openbmc_project.Led.Group";
@@ -43,9 +41,8 @@ enum class StatusSetting
 {
     none,
     ok,
-    warn,
-    critical,
-    fatal
+    dimmerr,
+    fault
 };
 
 constexpr const bool debug = false;
@@ -102,9 +99,8 @@ void updateLedStatus(std::shared_ptr<sdbusplus::asio::connection>& conn,
     std::vector<std::pair<std::string, std::variant<bool>>> ledsToSet;
     if (forceRefresh)
     {
-        ledsToSet.push_back(std::make_pair(fatalLedPath, false));
-        ledsToSet.push_back(std::make_pair(criticalLedPath, false));
-        ledsToSet.push_back(std::make_pair(warningLedPath, false));
+        ledsToSet.push_back(std::make_pair(faultLedPath, false));
+        ledsToSet.push_back(std::make_pair(dimmfaultLedPath, false));
         ledsToSet.push_back(std::make_pair(okLedPath, false));
         for (const auto& ledPair : ledsToSet)
         {
@@ -128,17 +124,14 @@ void updateLedStatus(std::shared_ptr<sdbusplus::asio::connection>& conn,
                 ledAssertProp, ledPair.second);
         }
     }
+
     if (fatal)
     {
-        currentPriority = StatusSetting::fatal;
+        currentPriority = StatusSetting::fault;
     }
     else if (critical)
     {
-        currentPriority = StatusSetting::critical;
-    }
-    else if (warn)
-    {
-        currentPriority = StatusSetting::warn;
+        currentPriority = StatusSetting::fault;
     }
     else
     {
@@ -149,35 +142,24 @@ void updateLedStatus(std::shared_ptr<sdbusplus::asio::connection>& conn,
     {
         switch (currentPriority)
         {
-            case (StatusSetting::fatal):
-            {
-                ledsToSet.push_back(std::make_pair(fatalLedPath, true));
-                ledsToSet.push_back(std::make_pair(criticalLedPath, false));
-                ledsToSet.push_back(std::make_pair(warningLedPath, false));
-                ledsToSet.push_back(std::make_pair(okLedPath, false));
-                break;
-            }
-            case (StatusSetting::critical):
+            case (StatusSetting::fault):
             {
-                ledsToSet.push_back(std::make_pair(fatalLedPath, false));
-                ledsToSet.push_back(std::make_pair(criticalLedPath, true));
-                ledsToSet.push_back(std::make_pair(warningLedPath, false));
                 ledsToSet.push_back(std::make_pair(okLedPath, false));
+                ledsToSet.push_back(std::make_pair(dimmfaultLedPath, false));
+                ledsToSet.push_back(std::make_pair(faultLedPath, true));
                 break;
             }
-            case (StatusSetting::warn):
+            case (StatusSetting::dimmerr):
             {
-                ledsToSet.push_back(std::make_pair(fatalLedPath, false));
-                ledsToSet.push_back(std::make_pair(criticalLedPath, false));
-                ledsToSet.push_back(std::make_pair(warningLedPath, true));
                 ledsToSet.push_back(std::make_pair(okLedPath, false));
+                ledsToSet.push_back(std::make_pair(faultLedPath, false));
+                ledsToSet.push_back(std::make_pair(dimmfaultLedPath, true));
                 break;
             }
             case (StatusSetting::ok):
             {
-                ledsToSet.push_back(std::make_pair(fatalLedPath, false));
-                ledsToSet.push_back(std::make_pair(criticalLedPath, false));
-                ledsToSet.push_back(std::make_pair(warningLedPath, false));
+                ledsToSet.push_back(std::make_pair(faultLedPath, false));
+                ledsToSet.push_back(std::make_pair(dimmfaultLedPath, false));
                 ledsToSet.push_back(std::make_pair(okLedPath, true));
                 break;
             }
-- 
2.34.1

