diff options
author | Patrick Venture <venture@google.com> | 2019-09-09 14:47:22 -0700 |
---|---|---|
committer | Patrick Venture <venture@google.com> | 2019-09-17 01:43:55 +0000 |
commit | db0cbe643bc8d017afd58903eb4aacd48f94361a (patch) | |
tree | ea80bdea2f083ebebb64e1f0e3d26164e2a4e2ee | |
parent | 235b3c76c354f9242192f56cab609ec9e53c0cc3 (diff) | |
download | phosphor-host-ipmid-db0cbe643bc8d017afd58903eb4aacd48f94361a.tar.gz phosphor-host-ipmid-db0cbe643bc8d017afd58903eb4aacd48f94361a.zip |
move sensors into ipmi::sensor namespace
The object was left in the global namespace, but the type was in the
ipmi::sensor namespace. Move the object into the namespace.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I88e46da4abda220d3b6fcc2ea64b8ef0decb0dc3
-rw-r--r-- | scripts/writesensor.mako.cpp | 6 | ||||
-rw-r--r-- | sensorhandler.cpp | 41 | ||||
-rw-r--r-- | storagehandler.cpp | 11 |
3 files changed, 39 insertions, 19 deletions
diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp index 192b858..c740f6f 100644 --- a/scripts/writesensor.mako.cpp +++ b/scripts/writesensor.mako.cpp @@ -27,7 +27,9 @@ interfaceDict = {} #include "sensordatahandler.hpp" #include <ipmid/types.hpp> -using namespace ipmi::sensor; + +namespace ipmi { +namespace sensor { extern const IdInfoMap sensors = { % for key in sensorDict.iterkeys(): @@ -145,3 +147,5 @@ except KeyError, e: % endfor }; +} // namespace sensor +} // namespace ipmi diff --git a/sensorhandler.cpp b/sensorhandler.cpp index 1901464..28b04c1 100644 --- a/sensorhandler.cpp +++ b/sensorhandler.cpp @@ -26,7 +26,15 @@ static constexpr uint8_t BMCSlaveAddress = 0x20; extern int updateSensorRecordFromSSRAESC(const void*); extern sd_bus* bus; -extern const ipmi::sensor::IdInfoMap sensors; + +namespace ipmi +{ +namespace sensor +{ +extern const IdInfoMap sensors; +} // namespace sensor +} // namespace ipmi + extern const FruMap frus; using namespace phosphor::logging; @@ -103,8 +111,8 @@ int find_openbmc_path(uint8_t num, dbus_interface_t* interface) { int rc; - const auto& sensor_it = sensors.find(num); - if (sensor_it == sensors.end()) + const auto& sensor_it = ipmi::sensor::sensors.find(num); + if (sensor_it == ipmi::sensor::sensors.end()) { // The sensor map does not contain the sensor requested return -EINVAL; @@ -380,8 +388,8 @@ ipmi::RspType<> ipmiSetSensorReading(uint8_t sensorNumber, uint8_t operation, cmdData.eventData3 = eventData3; // Check if the Sensor Number is present - const auto iter = sensors.find(sensorNumber); - if (iter == sensors.end()) + const auto iter = ipmi::sensor::sensors.find(sensorNumber); + if (iter == ipmi::sensor::sensors.end()) { updateSensorRecordFromSSRAESC(&sensorNumber); return ipmi::responseSuccess(); @@ -424,8 +432,8 @@ ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd, ipmi::sensor::GetSensorResponse getResponse{}; static constexpr auto scanningEnabledBit = 6; - const auto iter = sensors.find(reqptr->sennum); - if (iter == sensors.end()) + const auto iter = ipmi::sensor::sensors.find(reqptr->sennum); + if (iter == ipmi::sensor::sensors.end()) { return IPMI_CC_SENSOR_INVALID; } @@ -467,7 +475,7 @@ void getSensorThresholds(uint8_t sensorNum, sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; - const auto iter = sensors.find(sensorNum); + const auto iter = ipmi::sensor::sensors.find(sensorNum); const auto info = iter->second; auto service = ipmi::getService(bus, info.sensorInterface, info.sensorPath); @@ -541,8 +549,8 @@ ipmi_ret_t ipmi_sen_get_sensor_thresholds(ipmi_netfn_t netfn, ipmi_cmd_t cmd, auto sensorNum = *(reinterpret_cast<const uint8_t*>(request)); *data_len = 0; - const auto iter = sensors.find(sensorNum); - if (iter == sensors.end()) + const auto iter = ipmi::sensor::sensors.find(sensorNum); + if (iter == ipmi::sensor::sensors.end()) { return IPMI_CC_SENSOR_INVALID; } @@ -608,12 +616,13 @@ ipmi::RspType<uint8_t, // respcount { // Get SDR count. This returns the total number of SDRs in the device. const auto& entityRecords = ipmi::sensor::getIpmiEntityRecords(); - sdrCount = sensors.size() + frus.size() + entityRecords.size(); + sdrCount = + ipmi::sensor::sensors.size() + frus.size() + entityRecords.size(); } else if (count.value_or(0) == getSensorCount) { // Get Sensor count. This returns the number of sensors - sdrCount = sensors.size(); + sdrCount = ipmi::sensor::sensors.size(); } else { @@ -888,7 +897,7 @@ ipmi_ret_t ipmi_sen_get_sdr(ipmi_netfn_t netfn, ipmi_cmd_t cmd, // Note: we use an iterator so we can provide the next ID at the end of // the call. - auto sensor = sensors.begin(); + auto sensor = ipmi::sensor::sensors.begin(); auto recordID = get_sdr::request::get_record_id(req); // At the beginning of a scan, the host side will send us id=0. @@ -910,8 +919,8 @@ ipmi_ret_t ipmi_sen_get_sdr(ipmi_netfn_t netfn, ipmi_cmd_t cmd, } else { - sensor = sensors.find(recordID); - if (sensor == sensors.end()) + sensor = ipmi::sensor::sensors.find(recordID); + if (sensor == ipmi::sensor::sensors.end()) { return IPMI_CC_SENSOR_INVALID; } @@ -945,7 +954,7 @@ ipmi_ret_t ipmi_sen_get_sdr(ipmi_netfn_t netfn, ipmi_cmd_t cmd, ret = populate_record_from_dbus(&(record.body), &(sensor->second), data_len); - if (++sensor == sensors.end()) + if (++sensor == ipmi::sensor::sensors.end()) { // we have reached till end of sensor, so assign the next record id // to 256(Max Sensor ID = 255) + FRU ID(may start with 0). diff --git a/storagehandler.cpp b/storagehandler.cpp index 0932f72..96d3d54 100644 --- a/storagehandler.cpp +++ b/storagehandler.cpp @@ -27,7 +27,14 @@ void register_netfn_storage_functions() __attribute__((constructor)); unsigned int g_sel_time = 0xFFFFFFFF; -extern const ipmi::sensor::IdInfoMap sensors; +namespace ipmi +{ +namespace sensor +{ +extern const IdInfoMap sensors; +} // namespace sensor +} // namespace ipmi + extern const FruMap frus; constexpr uint8_t eventDataSize = 3; namespace @@ -725,7 +732,7 @@ ipmi::RspType<uint8_t, // SDR version constexpr uint32_t deletionTimestamp = 0x0; constexpr uint8_t operationSupport = 0; - uint16_t records = frus.size() + sensors.size(); + uint16_t records = frus.size() + ipmi::sensor::sensors.size(); return ipmi::responseSuccess(sdrVersion, records, freeSpace, additionTimestamp, deletionTimestamp, |