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>
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 @@
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()));
+ 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);
+ 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()));
+ log<level::INFO>("Logging failing sysfs file",
+ phosphor::logging::entry("FILE=%s", file.c_str()));
- exit(EXIT_FAILURE);
- }
+ exit(EXIT_FAILURE);
}
return FanPwmObject::target(value);