Log a PEL for communication, presence mismatch, and safe state errors
Add code to log a PEL in various error scenarios. Refactor some of the
error handling to get the return code out of the driver.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
Change-Id: Ifd91cfc063718e484ec8886df8357d115c6b41e3
diff --git a/occ_errors.cpp b/occ_errors.cpp
index c6f450d..f41173e 100644
--- a/occ_errors.cpp
+++ b/occ_errors.cpp
@@ -17,9 +17,6 @@
namespace occ
{
-// Value in error file indicating success
-constexpr auto NO_ERROR = '0';
-
using namespace phosphor::logging;
using namespace sdbusplus::org::open_power::OCC::Device::Error;
using InternalFailure =
@@ -113,6 +110,7 @@
void Error::analyzeEvent()
{
// Get the number of bytes to read
+ int err = 0;
int len = -1;
auto r = ioctl(fd, FIONREAD, &len);
if (r < 0)
@@ -127,10 +125,11 @@
// A non-zero data indicates an error condition
// Let the caller take appropriate action on this
auto data = readFile(len);
- bool error = !(data.empty() || data.front() == NO_ERROR);
+ if (!data.empty())
+ err = std::stoi(data, nullptr, 0);
if (callBack)
{
- callBack(error);
+ callBack(err);
}
return;
}