blob: 459b9d031ad195771e54496a684f4b0a4b8dbbc7 [file] [log] [blame]
Matthew Barth048ac872017-03-09 14:36:08 -06001#include "fan_speed.hpp"
2#include "hwmon.hpp"
3#include "sysfs.hpp"
Matt Spinler0a8de642017-05-11 10:59:39 -05004#include <experimental/filesystem>
Matthew Barth048ac872017-03-09 14:36:08 -06005
6namespace hwmon
7{
8
9uint64_t FanSpeed::target(uint64_t value)
10{
11 auto curValue = FanSpeedObject::target();
12
13 if (curValue != value)
14 {
15 //Write target out to sysfs
Patrick Venture1e6324f2017-06-01 14:07:05 -070016 curValue = sysfs::writeSysfsWithCallout(value,
17 sysfsRoot,
18 instance,
19 type,
20 id,
21 entry::target);
Matthew Barth048ac872017-03-09 14:36:08 -060022 }
23
24 return FanSpeedObject::target(value);
25}
26
Matt Spinler0a8de642017-05-11 10:59:39 -050027
28void FanSpeed::enable()
29{
30 namespace fs = std::experimental::filesystem;
31
32 auto path = sysfsRoot + "/" + instance;
Patrick Venture1e6324f2017-06-01 14:07:05 -070033 auto fullPath = sysfs::make_sysfs_path(path,
34 type::pwm,
35 id,
36 entry::enable);
Matt Spinler0a8de642017-05-11 10:59:39 -050037
38 if (fs::exists(fullPath))
39 {
40 //This class always uses RPM mode
Patrick Venture1e6324f2017-06-01 14:07:05 -070041 sysfs::writeSysfsWithCallout(enable::rpmMode,
42 sysfsRoot,
43 instance,
44 type::pwm,
45 id,
46 entry::enable);
Matt Spinler0a8de642017-05-11 10:59:39 -050047 }
48}
49
50
Matthew Barth048ac872017-03-09 14:36:08 -060051} // namespace hwmon