PEL: Common function to call host iface response

Add a function to the HostInterface class to invoke the user defined
command response function if there is one, and then change the code to
use this new function.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ia376923df70863bcd46120cf23918c2f255f984f
diff --git a/extensions/openpower-pels/host_interface.hpp b/extensions/openpower-pels/host_interface.hpp
index 94c984a..9aa880b 100644
--- a/extensions/openpower-pels/host_interface.hpp
+++ b/extensions/openpower-pels/host_interface.hpp
@@ -6,6 +6,7 @@
 
 #include <chrono>
 #include <functional>
+#include <phosphor-logging/log.hpp>
 #include <sdeventplus/event.hpp>
 #include <sdeventplus/source/io.hpp>
 
@@ -124,6 +125,29 @@
     }
 
     /**
+     * @brief Call the response function
+     *
+     * @param[in] status - The status given to the function
+     */
+    void callResponseFunc(ResponseStatus status)
+    {
+        if (_responseFunc)
+        {
+            try
+            {
+                (*_responseFunc)(status);
+            }
+            catch (const std::exception& e)
+            {
+                using namespace phosphor::logging;
+                log<level::ERR>(
+                    "Host iface response callback threw an exception",
+                    entry("ERROR=%s", e.what()));
+            }
+        }
+    }
+
+    /**
      * @brief Returns the event object in use
      *
      * @return sdeventplus::Event& - The event object
diff --git a/extensions/openpower-pels/pldm_interface.cpp b/extensions/openpower-pels/pldm_interface.cpp
index 20ecc53..87edb1c 100644
--- a/extensions/openpower-pels/pldm_interface.cpp
+++ b/extensions/openpower-pels/pldm_interface.cpp
@@ -225,18 +225,7 @@
         }
     }
 
-    if (_responseFunc)
-    {
-        try
-        {
-            (*_responseFunc)(status);
-        }
-        catch (const std::exception& e)
-        {
-            log<level::ERR>("PLDM response callback threw an exception",
-                            entry("ERROR=%s", e.what()));
-        }
-    }
+    callResponseFunc(status);
 
     if (responseMsg)
     {
@@ -249,18 +238,7 @@
     log<level::ERR>("Timed out waiting for PLDM response");
     cancelCmd();
 
-    if (_responseFunc)
-    {
-        try
-        {
-            (*_responseFunc)(ResponseStatus::failure);
-        }
-        catch (const std::exception& e)
-        {
-            log<level::ERR>("PLDM response callback threw an exception",
-                            entry("ERROR=%s", e.what()));
-        }
-    }
+    callResponseFunc(ResponseStatus::failure);
 }
 
 void PLDMInterface::cancelCmd()