Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 1 | #include "occ_status.hpp" |
| 2 | namespace open_power |
| 3 | { |
| 4 | namespace occ |
| 5 | { |
| 6 | |
| 7 | // Handles updates to occActive property |
| 8 | bool Status::occActive(bool value) |
| 9 | { |
Vishwanatha Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 10 | if (value != this->occActive()) |
| 11 | { |
| 12 | if (value) |
| 13 | { |
| 14 | // Bind the device |
| 15 | device.bind(); |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame^] | 16 | |
| 17 | // And watch for errors |
| 18 | device.addErrorWatch(); |
Vishwanatha Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 19 | } |
| 20 | else |
| 21 | { |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame^] | 22 | // Stop watching for errors |
| 23 | device.removeErrorWatch(); |
| 24 | |
| 25 | // Do the unbind. |
Vishwanatha Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 26 | device.unBind(); |
| 27 | } |
| 28 | } |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 29 | return Base::Status::occActive(value); |
| 30 | } |
| 31 | |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame^] | 32 | // Callback handler when a device error is reported. |
| 33 | void Status::deviceErrorHandler() |
| 34 | { |
| 35 | // This would deem OCC inactive |
| 36 | this->occActive(false); |
| 37 | } |
| 38 | |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 39 | } // namespace occ |
| 40 | } // namespace open_power |