Refactor : Add a helper function to addFruObjectToDbus
Refactoring addFruObjectToDbus function and created a new helper
function getProductName. Moved this function to fru_utils.cpp as
it is common for all fru-device deamons and avoid code duplication.
This patch is created based on suggestion on the below patch.
https://gerrit.openbmc.org/c/openbmc/entity-manager/+/51555
TESTED : Built Facebook YosemiteV2 images and loaded
on the target hardware. Verified all the fru's read and write.
Signed-off-by: Kumar Thangavel <thangavel.k@hcl.com>
Change-Id: I272d2fd2fc664a471774c668503d87147eb80a54
diff --git a/include/fru_utils.hpp b/include/fru_utils.hpp
index 20d1b66..64765b0 100644
--- a/include/fru_utils.hpp
+++ b/include/fru_utils.hpp
@@ -191,6 +191,7 @@
/// properties.
/// \return true on success false on failure. restFieldLoc and restFieldEnd
/// are updated.
+
bool copyRestFRUArea(std::vector<uint8_t>& fruData,
const std::string& propertyName,
struct FruArea& fruAreaParams,
@@ -207,3 +208,17 @@
std::pair<size_t, size_t>,
std::shared_ptr<sdbusplus::asio::dbus_interface>>& dbusInterfaceMap,
std::string& productName);
+
+/// \brief It does format fru data and find productName in the formatted
+/// fru data and return productName.
+/// \param device - vector that contains device list
+/// \param formattedFRU - map that contains formatted FRU data
+/// \param bus - bus number of the device
+/// \param address - address of the device
+/// \param unknownBusObjectCount - Unknown Bus object counter variable
+/// \return optional string. it returns productName or NULL
+
+std::optional<std::string> getProductName(
+ std::vector<uint8_t>& device,
+ boost::container::flat_map<std::string, std::string>& formattedFRU,
+ uint32_t bus, uint32_t address, size_t& unknownBusObjectCount);