summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--control/fan.cpp33
1 files changed, 8 insertions, 25 deletions
diff --git a/control/fan.cpp b/control/fan.cpp
index 40ec6b4..d4303cf 100644
--- a/control/fan.cpp
+++ b/control/fan.cpp
@@ -13,10 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <phosphor-logging/log.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/elog-errors.hpp>
-#include <xyz/openbmc_project/Common/error.hpp>
#include <string>
#include "fan.hpp"
#include "sdbusplus.hpp"
@@ -30,14 +26,10 @@ namespace control
// For throwing exception
using namespace phosphor::logging;
-using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
- Error::InternalFailure;
-constexpr auto PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties";
constexpr auto FAN_SENSOR_PATH = "/xyz/openbmc_project/sensors/fan_tach/";
constexpr auto FAN_TARGET_PROPERTY = "Target";
-
Fan::Fan(sdbusplus::bus::bus& bus, const FanDefinition& def):
_bus(bus),
_name(std::get<fanNamePos>(def)),
@@ -70,25 +62,16 @@ Fan::Fan(sdbusplus::bus::bus& bus, const FanDefinition& def):
void Fan::setSpeed(uint64_t speed)
{
- sdbusplus::message::variant<uint64_t> value = speed;
- std::string property{FAN_TARGET_PROPERTY};
-
for (auto& sensor : _sensors)
{
- auto method = _bus.new_method_call(sensor.second.c_str(),
- sensor.first.c_str(),
- PROPERTY_INTERFACE,
- "Set");
- method.append(_interface, property, value);
-
- auto response = _bus.call(method);
- if (response.is_method_error())
- {
- log<level::ERR>(
- "Failed call to set fan speed ",
- entry("SENSOR=%s", sensor.first));
- elog<InternalFailure>();
- }
+ auto value = speed;
+ util::SDBusPlus::setProperty<uint64_t>(
+ _bus,
+ sensor.second,
+ sensor.first,
+ _interface,
+ FAN_TARGET_PROPERTY,
+ std::move(value));
}
_targetSpeed = speed;
OpenPOWER on IntegriCloud