blob: 5e4c9fcf2d6e0a0c955dc0cebb1667cfc09522de (
plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#include "fan_speed.hpp"
#include "hwmon.hpp"
#include "sysfs.hpp"
#include <experimental/filesystem>
#include <phosphor-logging/elog-errors.hpp>
#include <xyz/openbmc_project/Control/Device/error.hpp>
using namespace phosphor::logging;
namespace hwmon
{
uint64_t FanSpeed::target(uint64_t value)
{
auto curValue = FanSpeedObject::target();
if (curValue != value)
{
//Write target out to sysfs
try
{
ioAccess.write(
value,
type,
id,
entry::target);
}
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()));
exit(EXIT_FAILURE);
}
}
return FanSpeedObject::target(value);
}
void FanSpeed::enable()
{
namespace fs = std::experimental::filesystem;
auto fullPath = sysfs::make_sysfs_path(ioAccess.path(),
type::pwm,
id,
entry::enable);
if (fs::exists(fullPath))
{
//This class always uses RPM mode
try
{
ioAccess.write(
enable::rpmMode,
type::pwm,
id,
entry::enable);
}
catch (const std::system_error& e)
{
using namespace sdbusplus::xyz::openbmc_project::Control::
Device::Error;
phosphor::logging::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()));
exit(EXIT_FAILURE);
}
}
}
} // namespace hwmon
|