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