Use hwmonio for attribute IO
Moves disparate error handling scenarios from the method doing the
IO to the call point.
Resolves openbmc/openbmc#2166
Change-Id: I3b6d2e175433dd8b2946ae60381901f2d7ca1798
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/targets.hpp b/targets.hpp
index 86058ca..863eae5 100644
--- a/targets.hpp
+++ b/targets.hpp
@@ -31,8 +31,7 @@
* @tparam T - The target type
*
* @param[in] sensor - A sensor type and name
- * @param[in] hwmonRoot - The root hwmon path
- * @param[in] instance - The target instance name
+ * @param[in] instance - The target instance path
* @param[in] info - The sdbusplus server connection and interfaces
*
* @return A shared pointer to the target interface object
@@ -40,8 +39,8 @@
*/
template <typename T>
std::shared_ptr<T> addTarget(const SensorSet::key_type& sensor,
- const std::string& hwmonRoot,
- const std::string& instance,
+ const std::string& instancePath,
+ const std::string& devPath,
ObjectInfo& info)
{
std::shared_ptr<T> target;
@@ -53,15 +52,14 @@
auto& objPath = std::get<std::string>(info);
// Check if target sysfs file exists
- auto targetPath = hwmonRoot + '/' + instance;
- auto sysfsFullPath = sysfs::make_sysfs_path(targetPath,
+ auto sysfsFullPath = sysfs::make_sysfs_path(instancePath,
sensor.first,
sensor.second,
hwmon::entry::target);
if (fs::exists(sysfsFullPath))
{
- target = std::make_shared<T>(hwmonRoot,
- instance,
+ target = std::make_shared<T>(instancePath,
+ devPath,
sensor.second,
bus,
objPath.c_str(),