blob: 83825c5031e6072aed3545ea320ea3893eda4123 [file] [log] [blame]
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +05301#include "occ_status.hpp"
2namespace open_power
3{
4namespace occ
5{
6
7// Handles updates to occActive property
8bool Status::occActive(bool value)
9{
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053010 if (value != this->occActive())
11 {
12 if (value)
13 {
14 // Bind the device
15 device.bind();
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053016
17 // And watch for errors
18 device.addErrorWatch();
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053019 }
20 else
21 {
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053022 // Stop watching for errors
23 device.removeErrorWatch();
24
25 // Do the unbind.
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053026 device.unBind();
27 }
28 }
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053029 return Base::Status::occActive(value);
30}
31
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053032// Callback handler when a device error is reported.
33void Status::deviceErrorHandler()
34{
35 // This would deem OCC inactive
36 this->occActive(false);
37}
38
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053039} // namespace occ
40} // namespace open_power