summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2017-10-16 13:15:18 -0500
committerMatt Spinler <spinler@us.ibm.com>2017-10-24 11:41:21 -0500
commitb778df0ec874a2c73ae7dbed458bd5a04a3165f9 (patch)
treee215dd509571779427c7363fbc0e07250ccd808b
parentccfc77b6e84c566ca211842e5698ad36cb0e1d72 (diff)
downloadphosphor-hwmon-b778df0ec874a2c73ae7dbed458bd5a04a3165f9.tar.gz
phosphor-hwmon-b778df0ec874a2c73ae7dbed458bd5a04a3165f9.zip
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>
-rw-r--r--fan_speed.cpp28
-rw-r--r--fan_speed.hpp3
-rw-r--r--hwmon.hpp5
3 files changed, 17 insertions, 19 deletions
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 @@ uint64_t FanSpeed::target(uint64_t value)
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 @@ void FanSpeed::enable()
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()));
diff --git a/fan_speed.hpp b/fan_speed.hpp
index b47d718..3203178 100644
--- a/fan_speed.hpp
+++ b/fan_speed.hpp
@@ -48,7 +48,8 @@ class FanSpeed : public FanSpeedObject
uint64_t target(uint64_t value) override;
/**
- * @brief Writes the pwm_enable sysfs entry.
+ * @brief Writes the pwm_enable sysfs entry if the
+ * env var with the value to write is present
*/
void enable();
diff --git a/hwmon.hpp b/hwmon.hpp
index a64d564..5a4744c 100644
--- a/hwmon.hpp
+++ b/hwmon.hpp
@@ -17,11 +17,6 @@ static const std::string target = ctarget;
static const std::string enable = cenable;
}
-namespace enable
-{
-static const auto rpmMode = 2;
-}
-
namespace type
{
static constexpr auto cfan = "fan";
OpenPOWER on IntegriCloud