diff --git a/src/fans.cpp b/src/fans.cpp index 701451e..58e8976 100644 --- a/src/fans.cpp +++ b/src/fans.cpp @@ -210,10 +210,12 @@ HwmonFanDriver::HwmonFanDriver(const string &path) HwmonFanDriver::HwmonFanDriver( shared_ptr> hwmon_interface, bool optional, - opt max_errors + opt max_errors, + bool skip_save ) : FanDriver(optional, 0, max_errors) , hwmon_interface_(hwmon_interface) +, skip_save_(skip_save) {} @@ -221,6 +223,8 @@ HwmonFanDriver::~HwmonFanDriver() noexcept(false) { if (!initialized()) return; + if (skip_save_) + return; std::ofstream f(path() + "_enable"); if (!(f.is_open() && f.good())) { @@ -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); diff --git a/src/fans.h b/src/fans.h index 047ec25..337c242 100644 --- a/src/fans.h +++ b/src/fans.h @@ -83,7 +83,8 @@ class HwmonFanDriver : public FanDriver { HwmonFanDriver( shared_ptr> hwmon_interface, bool optional, - opt max_errors = nullopt + opt max_errors = nullopt, + bool skip_save = false ); virtual ~HwmonFanDriver() noexcept(false) override; @@ -96,6 +97,7 @@ class HwmonFanDriver : public FanDriver { private: shared_ptr> hwmon_interface_; + bool skip_save_; }; diff --git a/src/yamlconfig.cpp b/src/yamlconfig.cpp index e23b3c9..5ada402 100644 --- a/src/yamlconfig.cpp +++ b/src/yamlconfig.cpp @@ -280,7 +280,7 @@ bool convert_driver>>(const Node &node, vector(); @@ -289,6 +289,7 @@ bool convert_driver>>(const Node &node, vector() : false; opt> indices = decode_opt>(node[kw_indices]); opt max_errors = decode_opt(node[kw_max_errors]); + bool skip_save = node[kw_skip_save] ? node[kw_skip_save].as() : false; shared_ptr> hwmon_iface = std::make_shared>( path, name, model, indices @@ -301,7 +302,7 @@ bool convert_driver>>(const Node &node, vectorsize() : 1); ++i) - fans.push_back(wtf_ptr(new HwmonFanDriver(hwmon_iface, optional, max_errors))); + fans.push_back(wtf_ptr(new HwmonFanDriver(hwmon_iface, optional, max_errors, skip_save))); return true; } diff --git a/src/yamlconfig.h b/src/yamlconfig.h index 17365a8..2b36836 100644 --- a/src/yamlconfig.h +++ b/src/yamlconfig.h @@ -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<>