Add helper function to see if PMBus file exists
Due to some odd power supply behavior on some systems, certain PMBus
files in sysfs end up missing. Adding in a helper function to avoid
spurious tracing if an application so chooses to check for existence
before trying to read one of those files. See openbmc/openbmc#2364 issue
opened for this problem with the missing files.
Change-Id: Ib295beb7ff1733da6ecbcd6966b76b918ade7f54
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/pmbus.cpp b/pmbus.cpp
index 5fbbe3e..12b8aa8 100644
--- a/pmbus.cpp
+++ b/pmbus.cpp
@@ -127,6 +127,13 @@
return value != 0;
}
+bool PMBus::exists(const std::string& name, Type type)
+{
+ auto path = getPath(type);
+ path /= name;
+ return fs::exists(path);
+}
+
uint64_t PMBus::read(const std::string& name, Type type)
{
uint64_t data = 0;