Write pwmX_enable for fans that have a fanX_target
For fans that have a fanX_target hwmon sysfs attribute,
write the pwmX_enable on startup to put that fan into
RPM mode, which is safe to do because this application
requires that the target is written in RPMs. The write
will only occur if the pwm_enable file exists.
In the future, if fans with a target need to run in pwm
mode, this code will need to be updated to convert between
RPM and pwm anyway and the pwm_enable value can then
be different based on that.
Resolves openbmc/openbmc#1584
Change-Id: I4f6f3ac8d6651314367aaf5c51ac176220f1fba6
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/targets.hpp b/targets.hpp
index 381ba75..768d451 100644
--- a/targets.hpp
+++ b/targets.hpp
@@ -34,13 +34,17 @@
* @param[in] hwmonRoot - The root hwmon path
* @param[in] instance - The target instance name
* @param[in] info - The sdbusplus server connection and interfaces
+ *
+ * @return A shared pointer to the target interface object
+ * Will be empty if no interface was created
*/
template <typename T>
-void addTarget(const SensorSet::key_type& sensor,
- const std::string& hwmonRoot,
- const std::string& instance,
- ObjectInfo& info)
+std::shared_ptr<T> addTarget(const SensorSet::key_type& sensor,
+ const std::string& hwmonRoot,
+ const std::string& instance,
+ ObjectInfo& info)
{
+ std::shared_ptr<T> target;
namespace fs = std::experimental::filesystem;
static constexpr bool deferSignals = true;
@@ -56,13 +60,15 @@
hwmon::entry::target);
if (fs::exists(sysfsFullPath))
{
- auto iface = std::make_shared<T>(hwmonRoot,
- instance,
- sensor.second,
- bus,
- objPath.c_str(),
- deferSignals);
+ target = std::make_shared<T>(hwmonRoot,
+ instance,
+ sensor.second,
+ bus,
+ objPath.c_str(),
+ deferSignals);
auto type = Targets<T>::type;
- obj[type] = iface;
+ obj[type] = target;
}
+
+ return target;
}