Have the Target class manage the file descriptor

The sysfs file descriptor will now stay open from first
use until the Target class is destroyed.

Change-Id: Ib9803a527115cc75ecc9a5351d1e748ccd54a993
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/targeting.cpp b/targeting.cpp
index 11c359c..e7d8b7a 100644
--- a/targeting.cpp
+++ b/targeting.cpp
@@ -26,6 +26,18 @@
 using namespace phosphor::logging;
 namespace fs = std::experimental::filesystem;
 
+int Target::getCFAMFD()
+{
+    if (cfamFD.get() == nullptr)
+    {
+        cfamFD = std::make_unique<
+            openpower::util::FileDescriptor>(getCFAMPath());
+    }
+
+    return cfamFD->get();
+}
+
+
 Targeting::Targeting(const std::string& fsiMasterDev,
                      const std::string& fsiSlaveDir) :
     fsiMasterPath(fsiMasterDev),