Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 1 | #include "env.hpp" |
| 2 | #include "fan_pwm.hpp" |
| 3 | #include "hwmon.hpp" |
Patrick Venture | 75e56c6 | 2018-04-20 18:10:15 -0700 | [diff] [blame] | 4 | #include "hwmonio.hpp" |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 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 | { |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 21 | using namespace std::literals; |
| 22 | |
Kun Yi | 901f117 | 2018-06-14 10:23:03 -0700 | [diff] [blame^] | 23 | std::string empty; |
| 24 | //Write target out to sysfs |
| 25 | try |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 26 | { |
Kun Yi | 901f117 | 2018-06-14 10:23:03 -0700 | [diff] [blame^] | 27 | ioAccess->write( |
| 28 | value, |
| 29 | type, |
| 30 | id, |
| 31 | empty, |
| 32 | hwmonio::retries, |
| 33 | hwmonio::delay); |
| 34 | } |
| 35 | catch (const std::system_error& e) |
| 36 | { |
| 37 | using namespace sdbusplus::xyz::openbmc_project::Control:: |
| 38 | Device::Error; |
| 39 | report<WriteFailure>( |
| 40 | xyz::openbmc_project::Control::Device:: |
| 41 | WriteFailure::CALLOUT_ERRNO(e.code().value()), |
| 42 | xyz::openbmc_project::Control::Device:: |
| 43 | WriteFailure::CALLOUT_DEVICE_PATH(devPath.c_str())); |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 44 | |
Kun Yi | 901f117 | 2018-06-14 10:23:03 -0700 | [diff] [blame^] | 45 | auto file = sysfs::make_sysfs_path( |
| 46 | ioAccess->path(), |
| 47 | type, |
| 48 | id, |
| 49 | empty); |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 50 | |
Kun Yi | 901f117 | 2018-06-14 10:23:03 -0700 | [diff] [blame^] | 51 | log<level::INFO>("Logging failing sysfs file", |
| 52 | phosphor::logging::entry("FILE=%s", file.c_str())); |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 53 | |
Kun Yi | 901f117 | 2018-06-14 10:23:03 -0700 | [diff] [blame^] | 54 | exit(EXIT_FAILURE); |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | return FanPwmObject::target(value); |
| 58 | } |
| 59 | |
| 60 | } // namespace hwmon |
| 61 | |