summaryrefslogtreecommitdiffstats
path: root/occ_device.hpp
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-06-29 18:35:00 +0530
committerVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-07-29 23:57:59 +0530
commitee4d83dfc7b6cf3b5979541ab5b1918b68e6bbdb (patch)
tree4d186ddf133d77880e857fccdddb71fcc155a6bf /occ_device.hpp
parent554d60059e7d0b699b3cdcbe8de2c341613e9931 (diff)
downloadopenpower-occ-control-ee4d83dfc7b6cf3b5979541ab5b1918b68e6bbdb.tar.gz
openpower-occ-control-ee4d83dfc7b6cf3b5979541ab5b1918b68e6bbdb.zip
Add support to watch for OCC errors
Change-Id: I98d95020a2d01e281e5c8efa825d6b4bd4c6c160 Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
Diffstat (limited to 'occ_device.hpp')
-rw-r--r--occ_device.hpp37
1 files changed, 33 insertions, 4 deletions
diff --git a/occ_device.hpp b/occ_device.hpp
index dc057be..6538597 100644
--- a/occ_device.hpp
+++ b/occ_device.hpp
@@ -2,6 +2,8 @@
#include <fstream>
#include <experimental/filesystem>
+#include "occ_events.hpp"
+#include "occ_errors.hpp"
#include "config.h"
namespace open_power
{
@@ -25,10 +27,16 @@ class Device
/** @brief Constructs the Device object
*
- * @param[in] name - OCC instance name
+ * @param[in] event - Unique ptr reference to sd_event
+ * @param[in] name - OCC instance name
+ * @param[in] callback - Optional callback on errors
*/
- Device(const std::string& name) :
- config(name + '-' + "dev0")
+ Device(EventPtr& event,
+ const std::string& name,
+ std::function<void()> callBack = nullptr) :
+ config(name + '-' + "dev0"),
+ errorFile(fs::path(config) / "occ_error"),
+ error(event, errorFile, callBack)
{
// Nothing to do here
}
@@ -36,20 +44,38 @@ class Device
/** @brief Binds device to the OCC driver */
inline void bind()
{
+ // Bind the device
return write(bindPath, config);
}
/** @brief Un-binds device from the OCC driver */
inline void unBind()
{
- return write(unBindPath, config);
+ // Unbind the device
+ return write(unBindPath, config);
+ }
+
+ /** @brief Starts to monitor for errors */
+ inline void addErrorWatch()
+ {
+ return error.addWatch();
+ }
+
+ /** @brief stops monitoring for errors */
+ inline void removeErrorWatch()
+ {
+ return error.removeWatch();
}
private:
/** @brief Config value to be used to do bind and unbind */
const std::string config;
+ /** @brief This file contains 0 for success, non-zero for errors */
+ const fs::path errorFile;
+
/** @brief To bind the device to the OCC driver, do:
+ *
* Write occ<#>-dev0 to: /sys/bus/platform/drivers/occ-hwmon/bind
*/
static fs::path bindPath;
@@ -59,6 +85,9 @@ class Device
*/
static fs::path unBindPath;
+ /** Abstraction of error monitoring */
+ Error error;
+
/** @brief file writer to achieve bind and unbind
*
* @param[in] filename - Name of file to be written
OpenPOWER on IntegriCloud