Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 1 | #include "fan_pwm.hpp" |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 2 | |
| 3 | #include "env.hpp" |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 4 | #include "hwmon.hpp" |
Patrick Venture | 75e56c6 | 2018-04-20 18:10:15 -0700 | [diff] [blame] | 5 | #include "hwmonio.hpp" |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 6 | #include "sensorset.hpp" |
| 7 | #include "sysfs.hpp" |
| 8 | |
Patrick Venture | 9e997b4 | 2019-03-08 13:42:10 -0800 | [diff] [blame] | 9 | #include <filesystem> |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 10 | #include <phosphor-logging/elog-errors.hpp> |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 11 | #include <string> |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 12 | #include <xyz/openbmc_project/Control/Device/error.hpp> |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 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; |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 24 | // Write target out to sysfs |
Kun Yi | 901f117 | 2018-06-14 10:23:03 -0700 | [diff] [blame] | 25 | try |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 26 | { |
Patrick Venture | 2511c09 | 2018-12-19 14:31:29 -0800 | [diff] [blame] | 27 | _ioAccess->write(value, _type, _id, empty, hwmonio::retries, |
| 28 | hwmonio::delay); |
Kun Yi | 901f117 | 2018-06-14 10:23:03 -0700 | [diff] [blame] | 29 | } |
| 30 | catch (const std::system_error& e) |
| 31 | { |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 32 | using namespace sdbusplus::xyz::openbmc_project::Control::Device::Error; |
Kun Yi | 901f117 | 2018-06-14 10:23:03 -0700 | [diff] [blame] | 33 | report<WriteFailure>( |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 34 | xyz::openbmc_project::Control::Device::WriteFailure::CALLOUT_ERRNO( |
| 35 | e.code().value()), |
| 36 | xyz::openbmc_project::Control::Device::WriteFailure:: |
Patrick Venture | 2511c09 | 2018-12-19 14:31:29 -0800 | [diff] [blame] | 37 | CALLOUT_DEVICE_PATH(_devPath.c_str())); |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 38 | |
Patrick Venture | 2511c09 | 2018-12-19 14:31:29 -0800 | [diff] [blame] | 39 | auto file = |
| 40 | sysfs::make_sysfs_path(_ioAccess->path(), _type, _id, empty); |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 41 | |
Kun Yi | 901f117 | 2018-06-14 10:23:03 -0700 | [diff] [blame] | 42 | log<level::INFO>("Logging failing sysfs file", |
| 43 | phosphor::logging::entry("FILE=%s", file.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 | exit(EXIT_FAILURE); |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | return FanPwmObject::target(value); |
| 49 | } |
| 50 | |
| 51 | } // namespace hwmon |