diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2017-03-21 16:13:27 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-03-30 02:47:11 +0000 |
commit | 4e1f30f1da6827945087857f3df7164a352ff5cf (patch) | |
tree | 81f37c537a4df3a408a91cfd54423b3db3f366c0 /sysfs.cpp | |
parent | 048ac87fa06a2a1c42f51c9f87931271a4f5a401 (diff) | |
download | phosphor-hwmon-4e1f30f1da6827945087857f3df7164a352ff5cf.tar.gz phosphor-hwmon-4e1f30f1da6827945087857f3df7164a352ff5cf.zip |
Update sysfs reads
Log an error with a device callout on read failures
Change-Id: Ic9cd7ce3964e49879efd4bb19f197fd6a306773c
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'sysfs.cpp')
-rw-r--r-- | sysfs.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -19,6 +19,7 @@ #include <phosphor-logging/elog.hpp> #include <phosphor-logging/elog-errors.hpp> #include <xyz/openbmc_project/Control/Device/error.hpp> +#include <xyz/openbmc_project/Sensor/Device/error.hpp> #include "sysfs.hpp" #include "util.hpp" @@ -81,12 +82,20 @@ int readSysfsWithCallout(const std::string& root, // or read system calls that got us here. auto rc = errno; instancePath /= "device"; - phosphor::logging::log<phosphor::logging::level::ERR>( - strerror(rc), - phosphor::logging::entry( - "CALLOUT_DEVICE_PATH=%s", - fs::canonical(instancePath).c_str()), - phosphor::logging::entry("CALLOUT_ERRNO=%d", rc)); + using namespace sdbusplus::xyz::openbmc_project::Sensor::Device::Error; + try + { + elog<ReadFailure>( + xyz::openbmc_project::Sensor::Device:: + ReadFailure::CALLOUT_ERRNO(rc), + xyz::openbmc_project::Sensor::Device:: + ReadFailure::CALLOUT_DEVICE_PATH( + fs::canonical(instancePath).c_str())); + } + catch (ReadFailure& elog) + { + commit(elog.name()); + } exit(EXIT_FAILURE); } |