diff --git a/extensions/openpower-pels/callout.cpp b/extensions/openpower-pels/callout.cpp
index 0c45950..705b1e4 100644
--- a/extensions/openpower-pels/callout.cpp
+++ b/extensions/openpower-pels/callout.cpp
@@ -205,6 +205,54 @@
     }
 }
 
+bool Callout::operator==(const Callout& right) const
+{
+    if ((_locationCodeSize != 0) || (right.locationCodeSize() != 0))
+    {
+        return locationCode() == right.locationCode();
+    }
+
+    if (!_fruIdentity || !right.fruIdentity())
+    {
+        return false;
+    }
+
+    auto myProc = _fruIdentity->getMaintProc();
+    auto otherProc = right.fruIdentity()->getMaintProc();
+    if (myProc)
+    {
+        if (otherProc)
+        {
+            return *myProc == *otherProc;
+        }
+        return false;
+    }
+
+    auto myPN = _fruIdentity->getPN();
+    auto otherPN = right.fruIdentity()->getPN();
+    if (myPN && otherPN)
+    {
+        return *myPN == *otherPN;
+    }
+
+    return false;
+}
+
+bool Callout::operator>(const Callout& right) const
+{
+    // Treat all of the mediums the same
+    const std::map<std::uint8_t, int> priorities = {
+        {'H', 10}, {'M', 9}, {'A', 9}, {'B', 9}, {'C', 9}, {'L', 8}};
+
+    if (!priorities.contains(priority()) ||
+        !priorities.contains(right.priority()))
+    {
+        return false;
+    }
+
+    return priorities.at(priority()) > priorities.at(right.priority());
+}
+
 } // namespace src
 } // namespace pels
 } // namespace openpower
diff --git a/extensions/openpower-pels/callout.hpp b/extensions/openpower-pels/callout.hpp
index 9c99494..7ac0727 100644
--- a/extensions/openpower-pels/callout.hpp
+++ b/extensions/openpower-pels/callout.hpp
@@ -198,6 +198,16 @@
     }
 
     /**
+     * @brief Set the priority of the callout
+     *
+     * @param[in] priority - The priority value
+     */
+    void setPriority(uint8_t priority)
+    {
+        _priority = priority;
+    }
+
+    /**
      * @brief Returns the location code of the callout
      *
      * @return std::string - The location code
@@ -253,6 +263,25 @@
         return _mru;
     }
 
+    /**
+     * @brief Operator == used for finding duplicate callouts
+     *
+     * Checks if the location codes then maintenance procedure
+     * value, then symbolic FRU value match.
+     *
+     * @param[in] right - The callout to compare to
+     * @return bool - true if they are the same
+     */
+    bool operator==(const Callout& right) const;
+
+    /**
+     * @brief Operator > used for sorting callouts by priority
+     *
+     * @param[in] right - The callout to compare to
+     * @return bool - true if callout has higher priority than other
+     */
+    bool operator>(const Callout& right) const;
+
   private:
     /**
      * @brief Sets the location code field
diff --git a/extensions/openpower-pels/callouts.cpp b/extensions/openpower-pels/callouts.cpp
index 3ba3459..0cb1f7e 100644
--- a/extensions/openpower-pels/callouts.cpp
+++ b/extensions/openpower-pels/callouts.cpp
@@ -18,7 +18,6 @@
 #include <phosphor-logging/log.hpp>
 
 #include <algorithm>
-#include <map>
 
 namespace openpower
 {
@@ -53,28 +52,41 @@
 
 void Callouts::addCallout(std::unique_ptr<Callout> callout)
 {
-    if (_callouts.size() < maxNumberOfCallouts)
-    {
-        _callouts.push_back(std::move(callout));
+    bool shouldAdd = true;
 
-        _subsectionWordLength += _callouts.back()->flattenedSize() / 4;
-    }
-    else
+    // Check if there is already a callout for this FRU
+    auto it = std::ranges::find_if(
+        _callouts, [&callout](const auto& c) { return *callout == *c; });
+
+    // If the callout already exists, but the new one has a higher
+    // priority, change the existing callout's priority to this
+    // new value and don't add the new one.
+    if (it != _callouts.end())
     {
-        using namespace phosphor::logging;
-        log<level::INFO>("Dropping PEL callout because at max");
+        if (*callout > **it)
+        {
+            (*it)->setPriority(callout->priority());
+        }
+        shouldAdd = false;
     }
 
-    // Mapping including the  3 Medium levels as A,B and C
-    const std::map<std::uint8_t, int> priorities = {
-        {'H', 10}, {'M', 9}, {'A', 8}, {'B', 7}, {'C', 6}, {'L', 5}};
+    if (shouldAdd)
+    {
+        if (_callouts.size() < maxNumberOfCallouts)
+        {
+            _callouts.push_back(std::move(callout));
 
-    auto sortPriority = [&priorities](const std::unique_ptr<Callout>& p1,
-                                      const std::unique_ptr<Callout>& p2) {
-        return priorities.at(p1->priority()) > priorities.at(p2->priority());
-    };
+            _subsectionWordLength += _callouts.back()->flattenedSize() / 4;
+        }
+        else
+        {
+            using namespace phosphor::logging;
+            log<level::INFO>("Dropping PEL callout because at max");
+        }
+    }
 
-    std::sort(_callouts.begin(), _callouts.end(), sortPriority);
+    std::ranges::sort(_callouts,
+                      [](const auto& c1, const auto& c2) { return *c1 > *c2; });
 }
 
 } // namespace src
