Update hwmon fan target sysfs entries
Override the default FanSpeed.Target set implementation so when a target
value is written to the FanSpeed interface it is also updated in the
related fan target sysfs file. This sets a particular fan to the given
target speed.
Resolves openbmc/openbmc#962
Resolves openbmc/phosphor-hwmon#1
Change-Id: I867811737269b3f42d2a0dc15b37782a74f147b8
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/fan_speed.cpp b/fan_speed.cpp
new file mode 100644
index 0000000..74bbea3
--- /dev/null
+++ b/fan_speed.cpp
@@ -0,0 +1,26 @@
+#include "fan_speed.hpp"
+#include "hwmon.hpp"
+#include "sysfs.hpp"
+
+namespace hwmon
+{
+
+uint64_t FanSpeed::target(uint64_t value)
+{
+ auto curValue = FanSpeedObject::target();
+
+ if (curValue != value)
+ {
+ //Write target out to sysfs
+ curValue = writeSysfsWithCallout(value,
+ sysfsRoot,
+ instance,
+ type,
+ id,
+ entry::target);
+ }
+
+ return FanSpeedObject::target(value);
+}
+
+} // namespace hwmon