Add function to get PMBus device name

This will be used in the future to find a path
to certain sysfs files.

Change-Id: Ia919b2f954fddf7b97bd1c5025f7c54af942b318
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/pmbus.cpp b/pmbus.cpp
index 47560a0..b68f6fb 100644
--- a/pmbus.cpp
+++ b/pmbus.cpp
@@ -68,6 +68,29 @@
     }
 }
 
+std::string PMBus::getDeviceName()
+{
+    std::string name;
+    std::ifstream file;
+    auto path = basePath / "name";
+
+    file.exceptions(std::ifstream::failbit |
+                    std::ifstream::badbit |
+                    std::ifstream::eofbit);
+    try
+    {
+        file.open(path);
+        file >> name;
+    }
+    catch (std::exception& e)
+    {
+        log<level::ERR>("Unable to read PMBus device name",
+                        entry("PATH=%s", path.c_str()));
+    }
+
+    return name;
+}
+
 bool PMBus::readBitInPage(const std::string& name,
                           size_t page,
                           Type type)