summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--readeeprom.cpp25
-rw-r--r--strgfnhandler.cpp4
-rw-r--r--writefrudata.cpp7
-rw-r--r--writefrudata.hpp6
4 files changed, 14 insertions, 28 deletions
diff --git a/readeeprom.cpp b/readeeprom.cpp
index a9dd91d..d518a83 100644
--- a/readeeprom.cpp
+++ b/readeeprom.cpp
@@ -25,9 +25,6 @@ int main(int argc, char** argv)
int rc = 0;
uint8_t fruid = 0;
- // Handle to per process system bus
- sd_bus* bus_type = NULL;
-
// Read the arguments.
auto cli_options = std::make_unique<ArgumentParser>(argc, argv);
@@ -57,23 +54,11 @@ int main(int argc, char** argv)
// Finished getting options out, so release the parser.
cli_options.release();
- // Get a handle to System Bus
- rc = sd_bus_open_system(&bus_type);
- if (rc < 0)
- {
- log<level::ERR>("Failed to connect to system bus",
- entry("ERRNO=%s", std::strerror(-rc)));
- }
- else
- {
- // Now that we have the file that contains the eeprom data, go read it
- // and update the Inventory DB.
- bool bmc_fru = true;
- rc = validateFRUArea(fruid, eeprom_file.c_str(), bus_type, bmc_fru);
- }
-
- // Cleanup
- sd_bus_unref(bus_type);
+ // Now that we have the file that contains the eeprom data, go read it
+ // and update the Inventory DB.
+ auto bus = sdbusplus::bus::new_default();
+ bool bmc_fru = true;
+ rc = validateFRUArea(fruid, eeprom_file.c_str(), bus, bmc_fru);
return (rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
}
diff --git a/strgfnhandler.cpp b/strgfnhandler.cpp
index a00fc73..9526525 100644
--- a/strgfnhandler.cpp
+++ b/strgfnhandler.cpp
@@ -6,6 +6,7 @@
#include <cstdio>
#include <cstring>
#include <phosphor-logging/log.hpp>
+#include <sdbusplus/bus.hpp>
void register_netfn_storage_write_fru() __attribute__((constructor));
@@ -100,8 +101,9 @@ ipmi_ret_t ipmi_storage_write_fru_data(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
// We received some bytes. It may be full or partial. Send a valid
// FRU file to the inventory controller on DBus for the correct number
+ sdbusplus::bus::bus bus{bus_type};
bool bmc_fru = false;
- validateFRUArea(reqptr->frunum, fru_file_name, bus_type, bmc_fru);
+ validateFRUArea(reqptr->frunum, fru_file_name, bus, bmc_fru);
return rc;
}
diff --git a/writefrudata.cpp b/writefrudata.cpp
index 4fbbf72..02cff5f 100644
--- a/writefrudata.cpp
+++ b/writefrudata.cpp
@@ -144,7 +144,7 @@ auto getService(sdbusplus::bus::bus& bus, const std::string& intf,
// Takes FRU data, invokes Parser for each fru record area and updates
// Inventory
//------------------------------------------------------------------------
-int updateInventory(FruAreaVector& area_vec, sd_bus* bus_sd)
+int updateInventory(FruAreaVector& area_vec, sdbusplus::bus::bus& bus)
{
// Generic error reporter
int rc = 0;
@@ -173,7 +173,6 @@ int updateInventory(FruAreaVector& area_vec, sd_bus* bus_sd)
// Here we are just printing the object,interface and the properties.
// which needs to be called with the new inventory manager implementation.
- sdbusplus::bus::bus bus{bus_sd};
using namespace std::string_literals;
static const auto intf = "xyz.openbmc_project.Inventory.Manager"s;
static const auto path = "/xyz/openbmc_project/inventory"s;
@@ -514,7 +513,7 @@ int ipmi_validate_common_hdr(const uint8_t* fru_data, const size_t data_len)
// Accepts the filename and validates per IPMI FRU spec
//----------------------------------------------------
int validateFRUArea(const uint8_t fruid, const char* fru_file_name,
- sd_bus* bus_type, const bool bmc_fru)
+ sdbusplus::bus::bus& bus, const bool bmc_fru)
{
size_t data_len = 0;
size_t bytes_read = 0;
@@ -615,7 +614,7 @@ int validateFRUArea(const uint8_t fruid, const char* fru_file_name,
#ifdef __IPMI_DEBUG__
std::printf("\n SIZE of vector is : [%d] \n", fru_area_vec.size());
#endif
- rc = updateInventory(fru_area_vec, bus_type);
+ rc = updateInventory(fru_area_vec, bus);
if (rc < 0)
{
log<level::ERR>("Error updating inventory.");
diff --git a/writefrudata.hpp b/writefrudata.hpp
index e713bd5..072d4d3 100644
--- a/writefrudata.hpp
+++ b/writefrudata.hpp
@@ -1,7 +1,7 @@
#ifndef __IPMI_WRITE_FRU_DATA_H__
#define __IPMI_WRITE_FRU_DATA_H__
-#include <systemd/sd-bus.h>
+#include <sdbusplus/bus.hpp>
// IPMI commands for Storage net functions.
enum ipmi_netfn_storage_cmds
@@ -46,10 +46,10 @@ struct common_header
*
* @param[in] fruid - The ID to use for this FRU.
* @param[in] fru_file_name - the filename of the FRU.
- * @param[in] bus_type - a systemd bus for publishing the information.
+ * @param[in] bus - an sdbusplus systemd bus for publishing the information.
* @param[in] bmc_fru - If a particular area accessible only by BMC.
*/
int validateFRUArea(const uint8_t fruid, const char* fru_file_name,
- sd_bus* bus_type, const bool bmc_fru);
+ sdbusplus::bus::bus& bus, const bool bmc_fru);
#endif
OpenPOWER on IntegriCloud