From 2a58e2ce8032f020cb593f9a9adcb778b2e38c6a Mon Sep 17 00:00:00 2001 From: Brad Bishop Date: Sun, 30 Jul 2017 13:49:09 -0400 Subject: monitor: Use common wrapper methods Replace the implementation of readProperty with a call to the common property accessor in sdbusplus.hpp. Change-Id: Ic4ba75bad7458a99f3e29c9235e1a54ae62286fe Signed-off-by: Brad Bishop --- monitor/tach_sensor.cpp | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp index 6c7143a..bcdde0f 100644 --- a/monitor/tach_sensor.cpp +++ b/monitor/tach_sensor.cpp @@ -14,10 +14,8 @@ * limitations under the License. */ #include -#include -#include -#include #include "fan.hpp" +#include "sdbusplus.hpp" #include "tach_sensor.hpp" #include "../utility.hpp" @@ -28,10 +26,6 @@ namespace fan namespace monitor { -using namespace phosphor::logging; -using InternalFailure = sdbusplus::xyz::openbmc_project::Common:: - Error::InternalFailure; - constexpr auto PROPERTY_INTF = "org.freedesktop.DBus.Properties"; constexpr auto FAN_SENSOR_PATH = "/xyz/openbmc_project/sensors/fan_tach/"; constexpr auto FAN_SENSOR_CONTROL_INTF = "xyz.openbmc_project.Control.FanSpeed"; @@ -46,7 +40,6 @@ constexpr auto FAN_VALUE_PROPERTY = "Value"; * @param[in] interface - the interface the property is on * @param[in] propertName - the name of the property * @param[in] path - the dbus path - * @param[in] service - the dbus service * @param[in] bus - the dbus object * @param[out] value - filled in with the property value */ @@ -54,31 +47,15 @@ template static void readProperty(const std::string& interface, const std::string& propertyName, const std::string& path, - const std::string& service, sdbusplus::bus::bus& bus, T& value) { - sdbusplus::message::variant property; - try { - auto method = bus.new_method_call(service.c_str(), - path.c_str(), - PROPERTY_INTF, - "Get"); - - method.append(interface, propertyName); - - auto reply = bus.call(method); - if (reply.is_method_error()) - { - log("Error in property get call", - entry("PATH=%s", path.c_str())); - elog(); - } - - reply.read(property); - value = sdbusplus::message::variant_ns::get(property); + value = util::SDBusPlus::getProperty(bus, + path, + interface, + propertyName); } catch (std::exception& e) { @@ -100,13 +77,10 @@ TachSensor::TachSensor(sdbusplus::bus::bus& bus, _timeout(timeout), _timer(events, [this, &fan](){ fan.timerExpired(*this); }) { - auto service = getService(); - //Load in starting Target and Input values readProperty(FAN_SENSOR_VALUE_INTF, FAN_VALUE_PROPERTY, _name, - service, _bus, _tachInput); @@ -115,7 +89,6 @@ TachSensor::TachSensor(sdbusplus::bus::bus& bus, readProperty(FAN_SENSOR_CONTROL_INTF, FAN_TARGET_PROPERTY, _name, - service, _bus, _tachTarget); } -- cgit v1.2.1