PEL: Modify Repo::updatePEL behavior

The Repository class's updatePEL function takes a PEL and then
calls a passed in function to update it.

Change the behavior slightly so the callback returns a bool - true if
the PEL was actually updated, and false else.  That way the code knows
if the PEL needs to be written back out or not.

There is also a minor change to refresh the PEL attributes map for the
PEL inside the updatePEL function so it doesn't need to be done outside
of it.

This is all to support upcoming functionality where an updatePEL call
won't know if the PEL needs to be updated until the PEL fields can be
checked.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ic1eabd2fcd8dfc7f559be24142b3e147d4b65062
diff --git a/extensions/openpower-pels/repository.cpp b/extensions/openpower-pels/repository.cpp
index fa2020c..9bab95b 100644
--- a/extensions/openpower-pels/repository.cpp
+++ b/extensions/openpower-pels/repository.cpp
@@ -409,13 +409,12 @@
     {
         PELUpdateFunc func = [state](PEL& pel) {
             pel.setHostTransmissionState(state);
+            return true;
         };
 
         try
         {
             updatePEL(attr->second.path, func);
-
-            attr->second.hostState = state;
         }
         catch (const std::exception& e)
         {
@@ -436,13 +435,12 @@
     {
         PELUpdateFunc func = [state](PEL& pel) {
             pel.setHMCTransmissionState(state);
+            return true;
         };
 
         try
         {
             updatePEL(attr->second.path, func);
-
-            attr->second.hmcState = state;
         }
         catch (const std::exception& e)
         {
@@ -464,9 +462,28 @@
 
     if (pel.valid())
     {
-        updateFunc(pel);
+        if (updateFunc(pel))
+        {
+            // Three attribute fields can change post creation from
+            // an updatePEL call:
+            //  - hmcTransmissionState - When HMC acks a PEL
+            //  - hostTransmissionState - When host acks a PEL
+            //  - deconfig flag - Can be cleared for PELs that call out
+            //                    hotplugged FRUs.
+            // Make sure they're up to date.
+            LogID id{LogID::Pel(pel.id())};
+            auto attr =
+                std::find_if(_pelAttributes.begin(), _pelAttributes.end(),
+                             [&id](const auto& a) { return a.first == id; });
+            if (attr != _pelAttributes.end())
+            {
+                attr->second.hmcState = pel.hmcTransmissionState();
+                attr->second.hostState = pel.hostTransmissionState();
+                attr->second.deconfig = pel.getDeconfigFlag();
+            }
 
-        write(pel, path);
+            write(pel, path);
+        }
     }
     else
     {