mainloop: Cache devpath at startup
Currently the devpath is determined after a bus error to make
a callout. Finding the path at startup is less prone to race
conditions around ENOENT on driver unload in the event of a
callout.
Change-Id: I8ce8d9f630c8b7ecc398082002aa113ab352d3cb
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/mainloop.hpp b/mainloop.hpp
index d4ef2c4..90f1efa 100644
--- a/mainloop.hpp
+++ b/mainloop.hpp
@@ -29,6 +29,7 @@
*
* @param[in] bus - sdbusplus bus client connection.
* @param[in] path - hwmon sysfs instance to manage
+ * @param[in] devPath - physical device sysfs path.
* @param[in] prefix - DBus busname prefix.
* @param[in] root - DBus sensors namespace root.
*
@@ -41,6 +42,7 @@
MainLoop(
sdbusplus::bus::bus&& bus,
const std::string& path,
+ const std::string& devPath,
const char* prefix,
const char* root);
@@ -67,6 +69,8 @@
std::string _hwmonRoot;
/** @brief hwmon sysfs instance. */
std::string _instance;
+ /** @brief physical device sysfs path. */
+ std::string _devPath;
/** @brief DBus busname prefix. */
const char* _prefix;
/** @brief DBus sensors namespace root. */