sysfs: Removed unused code
A number of methods have been deprecated. Remove.
Change-Id: I87fa63724d67770719e93a85803fa37737d5cfad
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/sysfs.cpp b/sysfs.cpp
index cf1b384..5f53b31 100644
--- a/sysfs.cpp
+++ b/sysfs.cpp
@@ -18,13 +18,8 @@
#include <experimental/filesystem>
#include <fstream>
#include <memory>
-#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"
-using namespace phosphor::logging;
using namespace std::string_literals;
namespace fs = std::experimental::filesystem;
@@ -204,114 +199,6 @@
return emptyString;
}
-int readSysfsWithCallout(const std::string& root,
- const std::string& instance,
- const std::string& type,
- const std::string& id,
- const std::string& sensor,
- bool throwDeviceBusy)
-{
- namespace fs = std::experimental::filesystem;
-
- int value = 0;
- std::ifstream ifs;
- fs::path instancePath{root};
- instancePath /= instance;
- std::string fullPath = make_sysfs_path(instancePath,
- type, id, sensor);
-
- ifs.exceptions(std::ifstream::failbit
- | std::ifstream::badbit
- | std::ifstream::eofbit);
- try
- {
- ifs.open(fullPath);
- ifs >> value;
- }
- catch (const std::exception& e)
- {
- // Too many GCC bugs (53984, 66145) to do
- // this the right way...
-
- // errno should still reflect the error from the failing open
- // or read system calls that got us here.
- auto rc = errno;
-
- if ((rc == EAGAIN) && throwDeviceBusy)
- {
- throw DeviceBusyException(fullPath);
- }
-
- // If the directory disappeared then this application should gracefully
- // exit. There are race conditions between the unloading of a hwmon
- // driver and the stopping of this service by systemd. To prevent
- // this application from falsely failing in these scenarios, it will
- // simply exit if the directory or file can not be found. It is up
- // to the user(s) of this provided hwmon object to log the appropriate
- // errors if the object disappears when it should not.
- if (rc == ENOENT)
- {
- exit(0);
- }
- instancePath /= "device";
- auto callOutPath = findCalloutPath(instancePath);
- using namespace sdbusplus::xyz::openbmc_project::Sensor::Device::Error;
-
- // this throws a ReadFailure.
- elog<ReadFailure>(
- xyz::openbmc_project::Sensor::Device::
- ReadFailure::CALLOUT_ERRNO(rc),
- xyz::openbmc_project::Sensor::Device::
- ReadFailure::CALLOUT_DEVICE_PATH(callOutPath.c_str()));
- }
-
- return value;
-}
-
-uint64_t writeSysfsWithCallout(const uint64_t& value,
- const std::string& root,
- const std::string& instance,
- const std::string& type,
- const std::string& id,
- const std::string& sensor)
-{
- namespace fs = std::experimental::filesystem;
-
- std::string valueStr = std::to_string(value);
- std::ofstream ofs;
- fs::path instancePath{root};
- instancePath /= instance;
- std::string fullPath = make_sysfs_path(instancePath,
- type, id, sensor);
-
- ofs.exceptions(std::ofstream::failbit
- | std::ofstream::badbit
- | std::ofstream::eofbit);
- try
- {
- ofs.open(fullPath);
- ofs << valueStr;
- }
- catch (const std::exception& e)
- {
- // errno should still reflect the error from the failing open
- // or write system calls that got us here.
- auto rc = errno;
- instancePath /= "device";
- auto callOutPath = findCalloutPath(instancePath);
- using namespace sdbusplus::xyz::openbmc_project::Control::Device::Error;
- report<WriteFailure>(
- xyz::openbmc_project::Control::Device::
- WriteFailure::CALLOUT_ERRNO(rc),
- xyz::openbmc_project::Control::Device::
- WriteFailure::CALLOUT_DEVICE_PATH(callOutPath.c_str()));
-
- exit(EXIT_FAILURE);
- }
-
- return value;
-}
-
namespace hwmonio
{
diff --git a/sysfs.hpp b/sysfs.hpp
index a526198..934c7c2 100644
--- a/sysfs.hpp
+++ b/sysfs.hpp
@@ -6,24 +6,6 @@
namespace sysfs {
-/**
- * @class DeviceBusyException
- *
- * An internal exception which will be thrown when
- * readSysfsWithCallout() hits an EAGAIN. Will never bubble
- * up to terminate the application, nor does it need to be
- * reported.
- */
-class DeviceBusyException : public std::runtime_error
-{
- public:
-
- DeviceBusyException(const std::string& path) :
- std::runtime_error(path + " busy")
- {
- }
-};
-
inline std::string make_sysfs_path(const std::string& path,
const std::string& type,
const std::string& id,
@@ -75,47 +57,6 @@
*/
std::string findCalloutPath(const std::string& instancePath);
-/** @brief Read an hwmon sysfs value.
- *
- * Calls exit(3) with bad status on failure.
- *
- * @param[in] root - The hwmon class root.
- * @param[in] instance - The hwmon instance (ex. hwmon1).
- * @param[in] type - The hwmon type (ex. temp).
- * @param[in] id - The hwmon id (ex. 1).
- * @param[in] sensor - The hwmon sensor (ex. input).
- * @param[in] throwDeviceBusy - will throw a DeviceBusyException
- * on an EAGAIN errno instead of an error log exception.
- *
- * @returns - The read value.
- */
-int readSysfsWithCallout(const std::string& root,
- const std::string& instance,
- const std::string& type,
- const std::string& id,
- const std::string& sensor,
- bool throwDeviceBusy = true);
-
- /** @brief Write a hwmon sysfs value
- *
- * Calls exit(3) with bad status on failure
- *
- * @param[in] value - The value to be written
- * @param[in] root - The hwmon class root.
- * @param[in] instance - The hwmon instance (ex. hwmon1).
- * @param[in] type - The hwmon type (ex. fan).
- * @param[in] id - The hwmon id (ex. 1).
- * @param[in] sensor - The hwmon sensor (ex. target).
- *
- * @returns - The value written
- */
-uint64_t writeSysfsWithCallout(const uint64_t& value,
- const std::string& root,
- const std::string& instance,
- const std::string& type,
- const std::string& id,
- const std::string& sensor);
-
namespace hwmonio
{