Read fan target sysfs value on startup
When creating the object that represents the
Control.FanSpeed interface for a fan, read the
target fan speed out of sysfs and save it in
the object so it shows up in D-Bus immediately.
Previously the Target property would have a value
of zero until another application wrote it, leaving
a window where the D-Bus property wouldn't match
the underlying sysfs file value.
Change-Id: I08b149840c2cf731bc48f89118622fa63222600e
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/fan_speed.hpp b/fan_speed.hpp
index 3203178..7fc303a 100644
--- a/fan_speed.hpp
+++ b/fan_speed.hpp
@@ -26,18 +26,20 @@
* @param[in] bus - Dbus bus object
* @param[in] objPath - Dbus object path
* @param[in] defer - Dbus object registration defer
+ * @param[in] target - initial target speed value
*/
FanSpeed(const std::string& instancePath,
const std::string& devPath,
const std::string& id,
sdbusplus::bus::bus& bus,
const char* objPath,
- bool defer) : FanSpeedObject(bus, objPath, defer),
+ bool defer,
+ uint64_t target) : FanSpeedObject(bus, objPath, defer),
id(id),
ioAccess(instancePath),
devPath(devPath)
{
- // Nothing to do here
+ FanSpeedObject::target(target);
}
/**