forked from openbmc/phosphor-hwmon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fan_pwm.cpp
63 lines (51 loc) · 1.59 KB
/
fan_pwm.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "env.hpp"
#include "fan_pwm.hpp"
#include "hwmon.hpp"
#include "sensorset.hpp"
#include "sysfs.hpp"
#include <phosphor-logging/elog-errors.hpp>
#include <xyz/openbmc_project/Control/Device/error.hpp>
#include <experimental/filesystem>
#include <string>
using namespace phosphor::logging;
namespace hwmon
{
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 {
ioAccess.write(
value,
type,
id,
empty,
sysfs::hwmonio::retries,
sysfs::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);
log<level::INFO>("Logging failing sysfs file",
phosphor::logging::entry("FILE=%s", file.c_str()));
exit(EXIT_FAILURE);
}
}
return FanPwmObject::target(value);
}
} // namespace hwmon