Cleanup pcie code
Remove unused variable pcieService, fix pciePath and use global
variables pciePath and pcieDeviceInterface.
Tested: tested PCIeDeviceCollection and PCIeDevice, and tested
the changes with the peci-pcie commit
https://gerrit.openbmc.org/c/openbmc/peci-pcie/+/62100
Change-Id: Iff8aee3f8bc43740b1885a2da584b0e6cf579dcc
Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index a715acd..8dc922d 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -31,10 +31,9 @@
namespace redfish
{
-static constexpr char const* pcieService = "xyz.openbmc_project.PCIe";
-static constexpr char const* pciePath = "/xyz/openbmc_project/PCIe";
-static constexpr char const* pcieDeviceInterface =
- "xyz.openbmc_project.Inventory.Item.PCIeDevice";
+static constexpr char const* inventoryPath = "/xyz/openbmc_project/inventory";
+static constexpr std::array<std::string_view, 1> pcieDeviceInterface = {
+ "xyz.openbmc_project.Inventory.Item.PCIeDevice"};
static inline void handlePCIeDevicePath(
const std::string& pcieDeviceId,
@@ -79,11 +78,8 @@
const std::function<void(const std::string& pcieDevicePath,
const std::string& service)>& callback)
{
- constexpr std::array<std::string_view, 1> interfaces{
- "xyz.openbmc_project.Inventory.Item.PCIeDevice"};
-
dbus::utility::getSubTreePaths(
- "/xyz/openbmc_project/inventory", 0, interfaces,
+ inventoryPath, 0, pcieDeviceInterface,
[pcieDeviceId, aResp,
callback](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse&
@@ -104,7 +100,7 @@
const std::string& name)
{
dbus::utility::getSubTreePaths(
- pciePath, 1, {},
+ inventoryPath, 1, {},
[asyncResp, name](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse&
pcieDevicePaths) {
@@ -166,11 +162,9 @@
aResp->res.jsonValue["Members"] = nlohmann::json::array();
aResp->res.jsonValue["Members@odata.count"] = 0;
- constexpr std::array<std::string_view, 1> interfaces{
- "xyz.openbmc_project.Inventory.Item.PCIeDevice"};
collection_util::getCollectionMembers(
aResp, boost::urls::url("/redfish/v1/Systems/system/PCIeDevices"),
- interfaces);
+ pcieDeviceInterface);
}
inline void requestRoutesSystemPCIeDeviceCollection(App& app)