diff options
-rw-r--r-- | occ_device.hpp | 14 | ||||
-rw-r--r-- | occ_manager.hpp | 2 | ||||
-rw-r--r-- | occ_status.hpp | 11 |
3 files changed, 24 insertions, 3 deletions
diff --git a/occ_device.hpp b/occ_device.hpp index a2b4e85..3f7dff4 100644 --- a/occ_device.hpp +++ b/occ_device.hpp @@ -6,7 +6,6 @@ #include "occ_errors.hpp" #include "config.h" - namespace open_power { namespace occ @@ -61,6 +60,19 @@ class Device return write(unBindPath, config); } + /** @brief Returns if device is already bound. + * + * On device bind, a soft link by the name $config + * gets created in OCC_HWMON_PATH and gets removed + * on unbind + * + * @return true if bound, else false + */ + inline bool bound() const + { + return fs::exists(OCC_HWMON_PATH + config); + } + /** @brief Starts to monitor for errors */ inline void addErrorWatch() { diff --git a/occ_manager.hpp b/occ_manager.hpp index 7bb1042..0d32241 100644 --- a/occ_manager.hpp +++ b/occ_manager.hpp @@ -48,6 +48,7 @@ struct Manager // I2C OCC status objects are initialized directly initStatusObjects(); #else + // Check if CPU inventory exists already. auto occs = open_power::occ::finder::get(bus); if (occs.empty()) @@ -75,6 +76,7 @@ struct Manager #endif } + private: /** @brief Callback that responds to cpu creation in the inventory - * by creating the needed objects. diff --git a/occ_status.hpp b/occ_status.hpp index c097908..a334a2b 100644 --- a/occ_status.hpp +++ b/occ_status.hpp @@ -55,7 +55,7 @@ class Status : public Interface EventPtr& event, const char* path, std::function<void(bool)> callBack = nullptr) - : Interface(bus, path), + : Interface(bus, path, true), bus(bus), path(path), callBack(callBack), @@ -78,7 +78,14 @@ class Status : public Interface std::bind(std::mem_fn(&Status::hostControlEvent), this, std::placeholders::_1)) { - // Nothing to do here + // Check to see if we have OCC already bound. If so, just set it + if (device.bound()) + { + this->occActive(true); + } + + // Announce that we are ready + this->emit_object_added(); } /** @brief Since we are overriding the setter-occActive but not the |