summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKun Yi <kunyi731@gmail.com>2018-06-14 10:23:03 -0700
committerPatrick Venture <venture@google.com>2018-06-27 17:21:27 +0000
commit901f117733c828aa7519610eb23ce112b9d068a8 (patch)
treefa3cce9f5f73761c188b09fe0c532d9994a259e4
parent9f51481f3e1d48e5479624fb40f2df279152d453 (diff)
downloadphosphor-hwmon-901f117733c828aa7519610eb23ce112b9d068a8.tar.gz
phosphor-hwmon-901f117733c828aa7519610eb23ce112b9d068a8.zip
fan_pwm: Commit fan PWM value regardless of previous target.
Failure scenraio: set fan pwm => set fan auto => set fan pwm to the same value. DBus value would stay the same but the actual pwm value is already changed. Fix is to always commit the value to sysfs. Tested: Unit tests pass. Tested on hardware that setting DBus value on DBus always makes a pwm sysfs write. Change-Id: I8e2c22dd514543e10c9302c1adb0403ba6883a91 Signed-off-by: Kun Yi <kunyi731@gmail.com>
-rw-r--r--fan_pwm.cpp65
1 files changed, 31 insertions, 34 deletions
diff --git a/fan_pwm.cpp b/fan_pwm.cpp
index 9b43b17..1808f5d 100644
--- a/fan_pwm.cpp
+++ b/fan_pwm.cpp
@@ -18,43 +18,40 @@ namespace hwmon
uint64_t FanPwm::target(uint64_t value)
{
- auto curValue = FanPwmObject::target();
using namespace std::literals;
- if (curValue != value)
+ std::string empty;
+ //Write target out to sysfs
+ try
{
- std::string empty;
- //Write target out to sysfs
- try {
- ioAccess->write(
- value,
- type,
- id,
- empty,
- hwmonio::retries,
- hwmonio::delay);
- }
- catch (const std::system_error& e)
- {
- using namespace sdbusplus::xyz::openbmc_project::Control::
- Device::Error;
- report<WriteFailure>(
- xyz::openbmc_project::Control::Device::
- WriteFailure::CALLOUT_ERRNO(e.code().value()),
- xyz::openbmc_project::Control::Device::
- WriteFailure::CALLOUT_DEVICE_PATH(devPath.c_str()));
-
- auto file = sysfs::make_sysfs_path(
- ioAccess->path(),
- type,
- id,
- empty);
-
- log<level::INFO>("Logging failing sysfs file",
- phosphor::logging::entry("FILE=%s", file.c_str()));
-
- exit(EXIT_FAILURE);
- }
+ ioAccess->write(
+ value,
+ type,
+ id,
+ empty,
+ hwmonio::retries,
+ hwmonio::delay);
+ }
+ catch (const std::system_error& e)
+ {
+ using namespace sdbusplus::xyz::openbmc_project::Control::
+ Device::Error;
+ report<WriteFailure>(
+ xyz::openbmc_project::Control::Device::
+ WriteFailure::CALLOUT_ERRNO(e.code().value()),
+ xyz::openbmc_project::Control::Device::
+ WriteFailure::CALLOUT_DEVICE_PATH(devPath.c_str()));
+
+ auto file = sysfs::make_sysfs_path(
+ ioAccess->path(),
+ type,
+ id,
+ empty);
+
+ log<level::INFO>("Logging failing sysfs file",
+ phosphor::logging::entry("FILE=%s", file.c_str()));
+
+ exit(EXIT_FAILURE);
}
return FanPwmObject::target(value);
OpenPOWER on IntegriCloud