pinhole: move gpio function to utils

The function to read a GPIO is needed elsewhere in later reviews so move
to the utility file.

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I994d4a912c0abe9cae6cb02d22bf5be09581d332
diff --git a/chassis_state_manager.cpp b/chassis_state_manager.cpp
index fd2ef22..d23f348 100644
--- a/chassis_state_manager.cpp
+++ b/chassis_state_manager.cpp
@@ -2,11 +2,10 @@
 
 #include "chassis_state_manager.hpp"
 
+#include "utils.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 #include "xyz/openbmc_project/State/Shutdown/Power/error.hpp"
 
-#include <gpiod.h>
-
 #include <cereal/archives/json.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/lg2.hpp>
@@ -442,36 +441,21 @@
 {
     bool regulatorFault = false;
 
-    // find standby voltage regulator fault via gpio
-    gpiod_line* line = gpiod_line_find("regulator-standby-faulted");
+    // find standby voltage regulator fault via gpiog
 
-    if (nullptr != line)
+    auto gpioval = utils::getGpioValue("regulator-standby-faulted");
+
+    if (-1 == gpioval)
     {
-        // take ownership of gpio
-        if (0 != gpiod_line_request_input(line, "chassis"))
-        {
-            error("Failed request for regulator-standby-faulted GPIO");
-        }
-        else
-        {
-            // get gpio value
-            auto gpioval = gpiod_line_get_value(line);
-
-            // release ownership of gpio
-            gpiod_line_close_chip(line);
-
-            if (-1 == gpioval)
-            {
-                error("Failed reading regulator-standby-faulted GPIO");
-            }
-
-            if (1 == gpioval)
-            {
-                info("Detected standby voltage regulator fault");
-                regulatorFault = true;
-            }
-        }
+        error("Failed reading regulator-standby-faulted GPIO");
     }
+
+    if (1 == gpioval)
+    {
+        info("Detected standby voltage regulator fault");
+        regulatorFault = true;
+    }
+
     return regulatorFault;
 }