1 #include "env.hpp" 2 #include "fan_pwm.hpp" 3 #include "hwmon.hpp" 4 #include "hwmonio.hpp" 5 #include "sensorset.hpp" 6 #include "sysfs.hpp" 7 8 #include <phosphor-logging/elog-errors.hpp> 9 #include <xyz/openbmc_project/Control/Device/error.hpp> 10 11 #include <experimental/filesystem> 12 #include <string> 13 14 using namespace phosphor::logging; 15 16 namespace hwmon 17 { 18 19 uint64_t FanPwm::target(uint64_t value) 20 { 21 auto curValue = FanPwmObject::target(); 22 using namespace std::literals; 23 24 if (curValue != value) 25 { 26 std::string empty; 27 //Write target out to sysfs 28 try { 29 ioAccess.write( 30 value, 31 type, 32 id, 33 empty, 34 hwmonio::retries, 35 hwmonio::delay); 36 } 37 catch (const std::system_error& e) 38 { 39 using namespace sdbusplus::xyz::openbmc_project::Control:: 40 Device::Error; 41 report<WriteFailure>( 42 xyz::openbmc_project::Control::Device:: 43 WriteFailure::CALLOUT_ERRNO(e.code().value()), 44 xyz::openbmc_project::Control::Device:: 45 WriteFailure::CALLOUT_DEVICE_PATH(devPath.c_str())); 46 47 auto file = sysfs::make_sysfs_path( 48 ioAccess.path(), 49 type, 50 id, 51 empty); 52 53 log<level::INFO>("Logging failing sysfs file", 54 phosphor::logging::entry("FILE=%s", file.c_str())); 55 56 exit(EXIT_FAILURE); 57 } 58 } 59 60 return FanPwmObject::target(value); 61 } 62 63 } // namespace hwmon 64 65