Only write pwm_enable if it has an env var
Some device drivers don't need pwmX_enable written, so
only do it if an environment variable is present that
contains the value to write.
The environment variable is specified in the conf file
along with the other enviroment variables and would look like:
ENABLE_fan1 = "2"
Change-Id: I484ada60957cb0d2b133a69b36bf12cbaad948dc
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/fan_speed.cpp b/fan_speed.cpp
index 13aa266..2652f8d 100644
--- a/fan_speed.cpp
+++ b/fan_speed.cpp
@@ -1,9 +1,10 @@
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Control/Device/error.hpp>
+#include "sensorset.hpp"
+#include "env.hpp"
#include "fan_speed.hpp"
#include "hwmon.hpp"
#include "sysfs.hpp"
-#include <experimental/filesystem>
-#include <phosphor-logging/elog-errors.hpp>
-#include <xyz/openbmc_project/Control/Device/error.hpp>
using namespace phosphor::logging;
@@ -57,20 +58,15 @@
void FanSpeed::enable()
{
- namespace fs = std::experimental::filesystem;
-
- auto fullPath = sysfs::make_sysfs_path(ioAccess.path(),
- type::pwm,
- id,
- entry::enable);
-
- if (fs::exists(fullPath))
+ auto enable = getEnv("ENABLE", type, id);
+ if (!enable.empty())
{
- //This class always uses RPM mode
+ auto val = std::stoul(enable);
+
try
{
ioAccess.write(
- enable::rpmMode,
+ val,
type::pwm,
id,
entry::enable,
@@ -87,6 +83,12 @@
xyz::openbmc_project::Control::Device::
WriteFailure::CALLOUT_DEVICE_PATH(devPath.c_str()));
+ auto fullPath = sysfs::make_sysfs_path(
+ ioAccess.path(),
+ type::pwm,
+ id,
+ entry::enable);
+
log<level::INFO>("Logging failing sysfs file",
phosphor::logging::entry("FILE=%s", fullPath.c_str()));