blob: 1808f5d4930850bfd0698b248209c8257b7b1813 [file] [log] [blame]
Patrick Venture9331ab72018-01-29 09:48:47 -08001#include "env.hpp"
2#include "fan_pwm.hpp"
3#include "hwmon.hpp"
Patrick Venture75e56c62018-04-20 18:10:15 -07004#include "hwmonio.hpp"
Patrick Venture9331ab72018-01-29 09:48:47 -08005#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
14using namespace phosphor::logging;
15
16namespace hwmon
17{
18
19uint64_t FanPwm::target(uint64_t value)
20{
Patrick Venture9331ab72018-01-29 09:48:47 -080021 using namespace std::literals;
22
Kun Yi901f1172018-06-14 10:23:03 -070023 std::string empty;
24 //Write target out to sysfs
25 try
Patrick Venture9331ab72018-01-29 09:48:47 -080026 {
Kun Yi901f1172018-06-14 10:23:03 -070027 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 Venture9331ab72018-01-29 09:48:47 -080044
Kun Yi901f1172018-06-14 10:23:03 -070045 auto file = sysfs::make_sysfs_path(
46 ioAccess->path(),
47 type,
48 id,
49 empty);
Patrick Venture9331ab72018-01-29 09:48:47 -080050
Kun Yi901f1172018-06-14 10:23:03 -070051 log<level::INFO>("Logging failing sysfs file",
52 phosphor::logging::entry("FILE=%s", file.c_str()));
Patrick Venture9331ab72018-01-29 09:48:47 -080053
Kun Yi901f1172018-06-14 10:23:03 -070054 exit(EXIT_FAILURE);
Patrick Venture9331ab72018-01-29 09:48:47 -080055 }
56
57 return FanPwmObject::target(value);
58}
59
60} // namespace hwmon
61