blob: df6618cb4c149d37025acffc2b71961f13bd8eea [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
16 curValue = writeSysfsWithCallout(value,
17 sysfsRoot,
18 instance,
19 type,
20 id,
21 entry::target);
22 }
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;
33 auto fullPath = make_sysfs_path(path,
34 type::pwm,
35 id,
36 entry::enable);
37
38 if (fs::exists(fullPath))
39 {
40 //This class always uses RPM mode
41 writeSysfsWithCallout(enable::rpmMode,
42 sysfsRoot,
43 instance,
44 type::pwm,
45 id,
46 entry::enable);
47 }
48}
49
50
Matthew Barth048ac872017-03-09 14:36:08 -060051} // namespace hwmon