Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/fans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,21 @@ HwmonFanDriver::HwmonFanDriver(const string &path)
HwmonFanDriver::HwmonFanDriver(
shared_ptr<HwmonInterface<FanDriver>> hwmon_interface,
bool optional,
opt<unsigned int> max_errors
opt<unsigned int> max_errors,
bool skip_save
)
: FanDriver(optional, 0, max_errors)
, hwmon_interface_(hwmon_interface)
, skip_save_(skip_save)
{}


HwmonFanDriver::~HwmonFanDriver() noexcept(false)
{
if (!initialized())
return;
if (skip_save_)
return;

std::ofstream f(path() + "_enable");
if (!(f.is_open() && f.good())) {
Expand All @@ -238,6 +242,8 @@ HwmonFanDriver::~HwmonFanDriver() noexcept(false)

void HwmonFanDriver::init()
{
if (skip_save_)
return;
std::fstream f(path() + "_enable");
if (!(f.is_open() && f.good()))
throw IOerror(MSG_FAN_INIT(path()), errno);
Expand Down
4 changes: 3 additions & 1 deletion src/fans.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ class HwmonFanDriver : public FanDriver {
HwmonFanDriver(
shared_ptr<HwmonInterface<FanDriver>> hwmon_interface,
bool optional,
opt<unsigned int> max_errors = nullopt
opt<unsigned int> max_errors = nullopt,
bool skip_save = false
);

virtual ~HwmonFanDriver() noexcept(false) override;
Expand All @@ -96,6 +97,7 @@ class HwmonFanDriver : public FanDriver {

private:
shared_ptr<HwmonInterface<FanDriver>> hwmon_interface_;
bool skip_save_;
};


Expand Down
5 changes: 3 additions & 2 deletions src/yamlconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ bool convert_driver<vector<wtf_ptr<HwmonFanDriver>>>(const Node &node, vector<wt
return false;

allowed_keywords(node, {
kw_hwmon, kw_name, kw_indices, kw_optional, kw_max_errors, kw_levels
kw_hwmon, kw_name, kw_indices, kw_optional, kw_max_errors, kw_levels, kw_skip_save
});

string path = node[kw_hwmon].as<string>();
Expand All @@ -289,6 +289,7 @@ bool convert_driver<vector<wtf_ptr<HwmonFanDriver>>>(const Node &node, vector<wt
bool optional = node[kw_optional] ? node[kw_optional].as<bool>() : false;
opt<vector<unsigned int>> indices = decode_opt<vector<unsigned int>>(node[kw_indices]);
opt<unsigned int> max_errors = decode_opt<unsigned int>(node[kw_max_errors]);
bool skip_save = node[kw_skip_save] ? node[kw_skip_save].as<bool>() : false;

shared_ptr<HwmonInterface<FanDriver>> hwmon_iface = std::make_shared<HwmonInterface<FanDriver>>(
path, name, model, indices
Expand All @@ -301,7 +302,7 @@ bool convert_driver<vector<wtf_ptr<HwmonFanDriver>>>(const Node &node, vector<wt
);

for (unsigned int i = 0; i < (indices ? indices->size() : 1); ++i)
fans.push_back(wtf_ptr<HwmonFanDriver>(new HwmonFanDriver(hwmon_iface, optional, max_errors)));
fans.push_back(wtf_ptr<HwmonFanDriver>(new HwmonFanDriver(hwmon_iface, optional, max_errors, skip_save)));

return true;
}
Expand Down
1 change: 1 addition & 0 deletions src/yamlconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const string kw_indices("indices");
const string kw_correction("correction");
const string kw_optional("optional");
const string kw_max_errors("max_errors");
const string kw_skip_save("skip_save");


template<>
Expand Down