Allow Bus and Address to be Probed Separately
There are situations where we need to support only a bus probe or only an address probe.
We should allow probing separately of bus or address
#tlbmc
#tlbmc-redfish-aggregation
PiperOrigin-RevId: 820322435
Change-Id: I2a63ddbebd589498adc9260c1361960a8e863c4b
diff --git a/tlbmc/configs/entity_config_json_impl.cc b/tlbmc/configs/entity_config_json_impl.cc
index 17265ae..ae45471 100644
--- a/tlbmc/configs/entity_config_json_impl.cc
+++ b/tlbmc/configs/entity_config_json_impl.cc
@@ -429,6 +429,14 @@
RE2::FullMatch(find_fru_field->second, *probe_field));
}
+bool CheckI2cInfoMatchOrNull(const uint64_t* bus, const uint64_t* address,
+ const Fru& fru) {
+ bool bus_matches_or_null = bus == nullptr || *bus == fru.i2c_info().bus();
+ bool address_matches_or_null =
+ address == nullptr || *address == fru.i2c_info().address();
+ return bus_matches_or_null && address_matches_or_null;
+}
+
// Probes if the ipmi fru matches and updates the fru table and probed
// config map. Return true if probed successfully.
absl::StatusOr<bool> ProbeFru(nlohmann::json& ipmi_fru_object,
@@ -464,12 +472,8 @@
// Check if the FRU matches the probe.
for (const auto& [key, fru] : fru_table.key_to_fru()) {
- bool i2c_info_matches_or_null = false;
- if ((bus == nullptr && address == nullptr) ||
- (bus != nullptr && *bus == fru.i2c_info().bus() &&
- address != nullptr && *address == fru.i2c_info().address())) {
- i2c_info_matches_or_null = true;
- }
+ bool i2c_info_matches_or_null =
+ CheckI2cInfoMatchOrNull(bus, address, fru);
// Check if any of the FRU fields match the probe.
bool board_product_name_matches_or_null =