summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--presence/tach_sensor.cpp29
-rw-r--r--presence/tach_sensor.hpp37
2 files changed, 20 insertions, 46 deletions
diff --git a/presence/tach_sensor.cpp b/presence/tach_sensor.cpp
index c21478b..60da441 100644
--- a/presence/tach_sensor.cpp
+++ b/presence/tach_sensor.cpp
@@ -30,35 +30,18 @@ bool TachSensor::isPresent()
return (tach != 0);
}
-// Tach signal callback handler
-int TachSensor::handleTachChangeSignal(sd_bus_message* msg,
- void* usrData,
- sd_bus_error* err)
-{
- auto sdbpMsg = sdbusplus::message::message(msg);
- static_cast<TachSensor*>(usrData)->handleTachChange(sdbpMsg, err);
- return 0;
-}
-
-void TachSensor::handleTachChange(sdbusplus::message::message& sdbpMsg,
- sd_bus_error* err)
+void TachSensor::handleTachChange(sdbusplus::message::message& sdbpMsg)
{
std::string msgSensor;
std::map<std::string, sdbusplus::message::variant<int64_t>> msgData;
sdbpMsg.read(msgSensor, msgData);
- // TODO openbmc/phosphor-fan-presence#5
- // Update to use 'arg0namespace' match option to reduce dbus traffic
- // Find interface with value property
- if (msgSensor.compare("xyz.openbmc_project.Sensor.Value") == 0)
+ // Find the 'Value' property containing tach
+ auto valPropMap = msgData.find("Value");
+ if (valPropMap != msgData.end())
{
- // Find the 'Value' property containing tach
- auto valPropMap = msgData.find("Value");
- if (valPropMap != msgData.end())
- {
- tach = sdbusplus::message::variant_ns::get<int64_t>(
- valPropMap->second);
- }
+ tach = sdbusplus::message::variant_ns::get<int64_t>(
+ valPropMap->second);
}
// Update inventory according to latest tach reported
fanEnc.updInventory();
diff --git a/presence/tach_sensor.hpp b/presence/tach_sensor.hpp
index 90d955b..3de5d69 100644
--- a/presence/tach_sensor.hpp
+++ b/presence/tach_sensor.hpp
@@ -12,6 +12,8 @@ namespace fan
namespace presence
{
+using namespace sdbusplus::bus::match::rules;
+
/**
* @class TachSensor
* @brief OpenBMC Tach feedback sensor presence implementation
@@ -43,8 +45,10 @@ class TachSensor : public Sensor
bus(bus),
tachSignal(bus,
match(id).c_str(),
- handleTachChangeSignal,
- this)
+ std::bind(
+ std::mem_fn(&TachSensor::handleTachChange),
+ this,
+ std::placeholders::_1))
{
// Nothing to do here
}
@@ -73,32 +77,19 @@ class TachSensor : public Sensor
*/
static std::string match(const std::string& id)
{
- return std::string("type='signal',"
- "interface='org.freedesktop.DBus.Properties',"
- "member='PropertiesChanged',"
- "path='/xyz/openbmc_project/sensors/fan_tach/" +
- id + "'");
+ return std::string(
+ interface("org.freedesktop.DBus.Properties") +
+ member("PropertiesChanged") +
+ type::signal() +
+ path("/xyz/openbmc_project/sensors/fan_tach/" + id) +
+ argN(0, "xyz.openbmc_project.Sensor.Value"));
}
/**
- * @brief Callback function on tach change signals
- *
- * @param[out] msg - Data associated with the subscribed signal
- * @param[out] data - Pointer to this tach sensor object instance
- * @param[out] err - Contains any sdbus error reference if occurred
- *
- * @return 0
- */
- static int handleTachChangeSignal(sd_bus_message* msg,
- void* data,
- sd_bus_error* err);
- /**
- * @brief Determine & handle when the signal was a tach change
+ * @brief Handle when the signal was a tach change
*
* @param[in] msg - Expanded sdbusplus message data
- * @param[in] err - Contains any sdbus error reference if occurred
*/
- void handleTachChange(sdbusplus::message::message& msg,
- sd_bus_error* err);
+ void handleTachChange(sdbusplus::message::message& msg);
};
OpenPOWER on IntegriCloud