Fix build
Some components needed to be updated to cpp17 to support
std::variant and some components had incorrect dbus
interfaces for what is currently available. Fix it so it
builds.
Also re-clangformat some files
Tested-by: build passed
Change-Id: I4d43dc47a5facfc096dd6ccf64d098d796f11016
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/gpio/CMakeLists.txt b/gpio/CMakeLists.txt
index bd51f3e..b2d25ab 100644
--- a/gpio/CMakeLists.txt
+++ b/gpio/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
project(chassisgpio CXX)
-set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(LIBRARY_NAME "${PROJECT_NAME}")
diff --git a/power-control/CMakeLists.txt b/power-control/CMakeLists.txt
index e328e3e..1f9aba2 100644
--- a/power-control/CMakeLists.txt
+++ b/power-control/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
project(power-control CXX)
-set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
diff --git a/power-control/inc/power_control.hpp b/power-control/inc/power_control.hpp
index bc87cf6..f68b71d 100644
--- a/power-control/inc/power_control.hpp
+++ b/power-control/inc/power_control.hpp
@@ -25,7 +25,7 @@
#include <xyz/openbmc_project/Chassis/Control/Power/server.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
-//static constexpr size_t POLLING_INTERVAL_MS = 500;
+// static constexpr size_t POLLING_INTERVAL_MS = 500;
const static constexpr char* PGOOD_PIN = "PGOOD";
const static constexpr char* POWER_UP_PIN = "POWER_UP_PIN";
@@ -34,7 +34,7 @@
struct EventDeleter
{
- void operator()(sd_event *event) const
+ void operator()(sd_event* event) const
{
event = sd_event_unref(event);
}
@@ -42,15 +42,13 @@
using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
-
using pwr_control =
sdbusplus::xyz::openbmc_project::Chassis::Control::server::Power;
struct PowerControl : sdbusplus::server::object_t<pwr_control>
{
- PowerControl(sdbusplus::bus::bus& bus, const char* path,
- EventPtr &event,
- //phosphor::watchdog::EventPtr event,
+ PowerControl(sdbusplus::bus::bus& bus, const char* path, EventPtr& event,
+ // phosphor::watchdog::EventPtr event,
sd_event_io_handler_t handler = PowerControl::EventHandler) :
sdbusplus::server::object_t<pwr_control>(bus, path),
bus(bus), callbackHandler(handler)
@@ -71,21 +69,22 @@
closeGpio(pgood_fd);
throw std::runtime_error("failed to config POWER_UP_PIN");
}
-/*
- ret = sd_event_add_io(event.get(), nullptr, pgood_fd, EPOLLPRI,
- callbackHandler, this);
- if (ret < 0)
- {
- closeGpio(pgood_fd);
- closeGpio(power_up_fd);
- throw std::runtime_error("failed to add to event loop");
- }
+ /*
+ ret = sd_event_add_io(event.get(), nullptr, pgood_fd, EPOLLPRI,
+ callbackHandler, this);
+ if (ret < 0)
+ {
+ closeGpio(pgood_fd);
+ closeGpio(power_up_fd);
+ throw std::runtime_error("failed to add to event loop");
+ }
- timer.start(std::chrono::duration_cast<std::chrono::microseconds>(
- std::chrono::milliseconds(POLLING_INTERVAL_MS)));
- timer.setEnabled<std::true_type>();
- phosphor::logging::log<phosphor::logging::level::DEBUG>("Enable timer");
-*/
+ timer.start(std::chrono::duration_cast<std::chrono::microseconds>(
+ std::chrono::milliseconds(POLLING_INTERVAL_MS)));
+ timer.setEnabled<std::true_type>();
+ phosphor::logging::log<phosphor::logging::level::DEBUG>("Enable
+ timer");
+ */
}
~PowerControl()
@@ -146,7 +145,7 @@
}
else
{
- //powercontrol->powerLost();
+ // powercontrol->powerLost();
}
}
else
@@ -159,16 +158,17 @@
}
else
{
-// powercontrol->powerGood();
+ // powercontrol->powerGood();
}
}
return 0;
}
- int32_t forcePowerOff() override;
- int32_t setPowerState(int32_t newState) override;
- int32_t getPowerState() override;
+ bool forcePowerOff() override;
+ // todo: when dbus interfaces is fixed, these should be override
+ int32_t setPowerState(int32_t newState); // override;
+ int32_t getPowerState(); // override;
private:
int power_up_fd;
diff --git a/power-control/src/main.cpp b/power-control/src/main.cpp
index 676d65d..caea051 100644
--- a/power-control/src/main.cpp
+++ b/power-control/src/main.cpp
@@ -30,8 +30,8 @@
"Error creating a default sd_event handler");
return ret;
}
- //phosphor::watchdog::EventPtr eventP{event,
- // phosphor::watchdog::EventDeleter()};
+ // phosphor::watchdog::EventPtr eventP{event,
+ // phosphor::watchdog::EventDeleter()};
EventPtr eventP{event};
event = nullptr;
diff --git a/power-control/src/power_control.cpp b/power-control/src/power_control.cpp
index 9d15a06..3014370 100644
--- a/power-control/src/power_control.cpp
+++ b/power-control/src/power_control.cpp
@@ -15,11 +15,9 @@
*/
#include "power_control.hpp"
-int32_t PowerControl::forcePowerOff()
+bool PowerControl::forcePowerOff()
{
- int ret = 0;
-
- return ret;
+ return true;
}
int32_t PowerControl::setPowerState(int32_t newState)