| Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 1 | /** | 
|  | 2 | * Copyright © 2016 IBM Corporation | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *     http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
| Matt Spinler | f9c83c4 | 2017-08-10 08:51:45 -0500 | [diff] [blame] | 16 | #include "config.h" | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 17 |  | 
|  | 18 | #include "mainloop.hpp" | 
|  | 19 |  | 
| Patrick Venture | 0979185 | 2018-04-17 17:40:00 -0700 | [diff] [blame] | 20 | #include "env.hpp" | 
|  | 21 | #include "fan_pwm.hpp" | 
|  | 22 | #include "fan_speed.hpp" | 
| Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 23 | #include "hwmon.hpp" | 
| Patrick Venture | 75e56c6 | 2018-04-20 18:10:15 -0700 | [diff] [blame] | 24 | #include "hwmonio.hpp" | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 25 | #include "sensor.hpp" | 
| Patrick Venture | 0979185 | 2018-04-17 17:40:00 -0700 | [diff] [blame] | 26 | #include "sensorset.hpp" | 
| Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 27 | #include "sysfs.hpp" | 
| Matthew Barth | bf7b7b1 | 2017-03-07 15:46:59 -0600 | [diff] [blame] | 28 | #include "targets.hpp" | 
| Patrick Venture | 0979185 | 2018-04-17 17:40:00 -0700 | [diff] [blame] | 29 | #include "thresholds.hpp" | 
| Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 30 |  | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 31 | #include <cstdlib> | 
|  | 32 | #include <functional> | 
|  | 33 | #include <iostream> | 
|  | 34 | #include <memory> | 
|  | 35 | #include <phosphor-logging/elog-errors.hpp> | 
|  | 36 | #include <sstream> | 
|  | 37 | #include <string> | 
|  | 38 | #include <unordered_set> | 
| Patrick Venture | 1e6324f | 2017-06-01 14:07:05 -0700 | [diff] [blame] | 39 | #include <xyz/openbmc_project/Sensor/Device/error.hpp> | 
|  | 40 |  | 
|  | 41 | using namespace phosphor::logging; | 
|  | 42 |  | 
| Saqib Khan | 973886d | 2017-03-15 14:01:16 -0500 | [diff] [blame] | 43 | // Initialization for Warning Objects | 
|  | 44 | decltype(Thresholds<WarningObject>::setLo) Thresholds<WarningObject>::setLo = | 
|  | 45 | &WarningObject::warningLow; | 
|  | 46 | decltype(Thresholds<WarningObject>::setHi) Thresholds<WarningObject>::setHi = | 
|  | 47 | &WarningObject::warningHigh; | 
|  | 48 | decltype(Thresholds<WarningObject>::getLo) Thresholds<WarningObject>::getLo = | 
|  | 49 | &WarningObject::warningLow; | 
|  | 50 | decltype(Thresholds<WarningObject>::getHi) Thresholds<WarningObject>::getHi = | 
|  | 51 | &WarningObject::warningHigh; | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 52 | decltype( | 
|  | 53 | Thresholds<WarningObject>::alarmLo) Thresholds<WarningObject>::alarmLo = | 
| Saqib Khan | 973886d | 2017-03-15 14:01:16 -0500 | [diff] [blame] | 54 | &WarningObject::warningAlarmLow; | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 55 | decltype( | 
|  | 56 | Thresholds<WarningObject>::alarmHi) Thresholds<WarningObject>::alarmHi = | 
| Saqib Khan | 973886d | 2017-03-15 14:01:16 -0500 | [diff] [blame] | 57 | &WarningObject::warningAlarmHigh; | 
|  | 58 |  | 
|  | 59 | // Initialization for Critical Objects | 
|  | 60 | decltype(Thresholds<CriticalObject>::setLo) Thresholds<CriticalObject>::setLo = | 
|  | 61 | &CriticalObject::criticalLow; | 
|  | 62 | decltype(Thresholds<CriticalObject>::setHi) Thresholds<CriticalObject>::setHi = | 
|  | 63 | &CriticalObject::criticalHigh; | 
|  | 64 | decltype(Thresholds<CriticalObject>::getLo) Thresholds<CriticalObject>::getLo = | 
|  | 65 | &CriticalObject::criticalLow; | 
|  | 66 | decltype(Thresholds<CriticalObject>::getHi) Thresholds<CriticalObject>::getHi = | 
|  | 67 | &CriticalObject::criticalHigh; | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 68 | decltype( | 
|  | 69 | Thresholds<CriticalObject>::alarmLo) Thresholds<CriticalObject>::alarmLo = | 
| Saqib Khan | 973886d | 2017-03-15 14:01:16 -0500 | [diff] [blame] | 70 | &CriticalObject::criticalAlarmLow; | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 71 | decltype( | 
|  | 72 | Thresholds<CriticalObject>::alarmHi) Thresholds<CriticalObject>::alarmHi = | 
| Saqib Khan | 973886d | 2017-03-15 14:01:16 -0500 | [diff] [blame] | 73 | &CriticalObject::criticalAlarmHigh; | 
|  | 74 |  | 
| Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 75 | std::string MainLoop::getID(SensorSet::container_t::const_reference sensor) | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 76 | { | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 77 | std::string id; | 
|  | 78 |  | 
|  | 79 | /* | 
|  | 80 | * Check if the value of the MODE_<item><X> env variable for the sensor | 
| Matt Spinler | 7c42480 | 2018-05-04 10:52:40 -0500 | [diff] [blame] | 81 | * is set. If it is, then read the from the <item><X>_<mode> | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 82 | * file. The name of the DBUS object would be the value of the env | 
| Matt Spinler | 7c42480 | 2018-05-04 10:52:40 -0500 | [diff] [blame] | 83 | * variable LABEL_<item><mode value>. If the MODE_<item><X> env variable | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 84 | * doesn't exist, then the name of DBUS object is the value of the env | 
|  | 85 | * variable LABEL_<item><X>. | 
| Matt Spinler | 7c42480 | 2018-05-04 10:52:40 -0500 | [diff] [blame] | 86 | * | 
|  | 87 | * For example, if MODE_temp1 = "label", then code reads the temp1_label | 
|  | 88 | * file.  If it has a 5 in it, then it will use the following entry to | 
|  | 89 | * name the object: LABEL_temp5 = "My DBus object name". | 
|  | 90 | * | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 91 | */ | 
| Patrick Venture | 7a5285d | 2018-04-17 19:15:05 -0700 | [diff] [blame] | 92 | auto mode = env::getEnv("MODE", sensor.first); | 
| Matt Spinler | 7c42480 | 2018-05-04 10:52:40 -0500 | [diff] [blame] | 93 | if (!mode.empty()) | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 94 | { | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 95 | id = env::getIndirectID(_hwmonRoot + '/' + _instance + '/', mode, | 
|  | 96 | sensor.first); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 97 |  | 
|  | 98 | if (id.empty()) | 
|  | 99 | { | 
| Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 100 | return id; | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 101 | } | 
|  | 102 | } | 
|  | 103 |  | 
|  | 104 | // Use the ID we looked up above if there was one, | 
|  | 105 | // otherwise use the standard one. | 
|  | 106 | id = (id.empty()) ? sensor.first.second : id; | 
|  | 107 |  | 
| Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 108 | return id; | 
|  | 109 | } | 
|  | 110 |  | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 111 | SensorIdentifiers | 
|  | 112 | MainLoop::getIdentifiers(SensorSet::container_t::const_reference sensor) | 
| Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 113 | { | 
|  | 114 | std::string id = getID(sensor); | 
|  | 115 | std::string label; | 
|  | 116 |  | 
|  | 117 | if (!id.empty()) | 
|  | 118 | { | 
|  | 119 | // Ignore inputs without a label. | 
|  | 120 | label = env::getEnv("LABEL", sensor.first.first, id); | 
|  | 121 | } | 
|  | 122 |  | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 123 | return std::make_tuple(std::move(id), std::move(label)); | 
| Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 124 | } | 
|  | 125 |  | 
|  | 126 | /** | 
|  | 127 | * Reads the environment parameters of a sensor and creates an object with | 
|  | 128 | * atleast the `Value` interface, otherwise returns without creating the object. | 
|  | 129 | * If the `Value` interface is successfully created, by reading the sensor's | 
|  | 130 | * corresponding sysfs file's value, the additional interfaces for the sensor | 
| Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 131 | * are created and the InterfacesAdded signal is emitted. The object's state | 
|  | 132 | * data is then returned for sensor state monitoring within the main loop. | 
| Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 133 | */ | 
| William A. Kennington III | 4cbdfef | 2018-10-18 19:19:51 -0700 | [diff] [blame] | 134 | std::optional<ObjectStateData> | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 135 | MainLoop::getObject(SensorSet::container_t::const_reference sensor) | 
| Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 136 | { | 
|  | 137 | auto properties = getIdentifiers(sensor); | 
|  | 138 | if (std::get<sensorID>(properties).empty() || | 
|  | 139 | std::get<sensorLabel>(properties).empty()) | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 140 | { | 
| Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 141 | return {}; | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 142 | } | 
|  | 143 |  | 
| Patrick Venture | 0979185 | 2018-04-17 17:40:00 -0700 | [diff] [blame] | 144 | hwmon::Attributes attrs; | 
|  | 145 | if (!hwmon::getAttributes(sensor.first.first, attrs)) | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 146 | { | 
| Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 147 | return {}; | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 148 | } | 
|  | 149 |  | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 150 | auto sensorObj = | 
|  | 151 | std::make_unique<sensor::Sensor>(sensor.first, ioAccess, _devPath); | 
| Matthew Barth | 9c43106 | 2018-05-07 13:55:29 -0500 | [diff] [blame] | 152 |  | 
| Matthew Barth | b798527 | 2018-04-17 10:50:36 -0500 | [diff] [blame] | 153 | // Get list of return codes for removing sensors on device | 
|  | 154 | auto devRmRCs = env::getEnv("REMOVERCS"); | 
|  | 155 | // Add sensor removal return codes defined at the device level | 
| Matthew Barth | cb3daaf | 2018-05-07 15:03:16 -0500 | [diff] [blame] | 156 | sensorObj->addRemoveRCs(devRmRCs); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 157 |  | 
|  | 158 | std::string objectPath{_root}; | 
|  | 159 | objectPath.append(1, '/'); | 
| Patrick Venture | 0979185 | 2018-04-17 17:40:00 -0700 | [diff] [blame] | 160 | objectPath.append(hwmon::getNamespace(attrs)); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 161 | objectPath.append(1, '/'); | 
| Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 162 | objectPath.append(std::get<sensorLabel>(properties)); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 163 |  | 
|  | 164 | ObjectInfo info(&_bus, std::move(objectPath), Object()); | 
| Patrick Venture | 75e56c6 | 2018-04-20 18:10:15 -0700 | [diff] [blame] | 165 | RetryIO retryIO(hwmonio::retries, hwmonio::delay); | 
| Matthew Barth | d4beecf | 2018-04-03 15:50:22 -0500 | [diff] [blame] | 166 | if (rmSensors.find(sensor.first) != rmSensors.end()) | 
|  | 167 | { | 
|  | 168 | // When adding a sensor that was purposely removed, | 
|  | 169 | // don't retry on errors when reading its value | 
|  | 170 | std::get<size_t>(retryIO) = 0; | 
|  | 171 | } | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 172 | auto valueInterface = static_cast<std::shared_ptr<ValueObject>>(nullptr); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 173 | try | 
|  | 174 | { | 
| Matthew Barth | ca44c2e | 2018-04-24 15:33:25 -0500 | [diff] [blame] | 175 | // Add status interface based on _fault file being present | 
| Matthew Barth | 2e41b13 | 2018-05-07 14:15:45 -0500 | [diff] [blame] | 176 | sensorObj->addStatus(info); | 
| Matthew Barth | cb3daaf | 2018-05-07 15:03:16 -0500 | [diff] [blame] | 177 | valueInterface = sensorObj->addValue(retryIO, info); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 178 | } | 
|  | 179 | catch (const std::system_error& e) | 
|  | 180 | { | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 181 | auto file = | 
|  | 182 | sysfs::make_sysfs_path(ioAccess.path(), sensor.first.first, | 
|  | 183 | sensor.first.second, hwmon::entry::cinput); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 184 | #ifndef REMOVE_ON_FAIL | 
|  | 185 | // Check sensorAdjusts for sensor removal RCs | 
| Matthew Barth | ac47309 | 2018-05-07 14:41:46 -0500 | [diff] [blame] | 186 | auto& sAdjusts = sensorObj->getAdjusts(); | 
|  | 187 | if (sAdjusts.rmRCs.count(e.code().value()) > 0) | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 188 | { | 
| Matthew Barth | ac47309 | 2018-05-07 14:41:46 -0500 | [diff] [blame] | 189 | // Return code found in sensor return code removal list | 
|  | 190 | if (rmSensors.find(sensor.first) == rmSensors.end()) | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 191 | { | 
| Matthew Barth | ac47309 | 2018-05-07 14:41:46 -0500 | [diff] [blame] | 192 | // Trace for sensor not already removed from dbus | 
|  | 193 | log<level::INFO>("Sensor not added to dbus for read fail", | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 194 | entry("FILE=%s", file.c_str()), | 
|  | 195 | entry("RC=%d", e.code().value())); | 
|  | 196 | rmSensors[std::move(sensor.first)] = std::move(sensor.second); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 197 | } | 
| Matthew Barth | ac47309 | 2018-05-07 14:41:46 -0500 | [diff] [blame] | 198 | return {}; | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 199 | } | 
|  | 200 | #endif | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 201 | using namespace sdbusplus::xyz::openbmc_project::Sensor::Device::Error; | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 202 | report<ReadFailure>( | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 203 | xyz::openbmc_project::Sensor::Device::ReadFailure::CALLOUT_ERRNO( | 
|  | 204 | e.code().value()), | 
|  | 205 | xyz::openbmc_project::Sensor::Device::ReadFailure:: | 
|  | 206 | CALLOUT_DEVICE_PATH(_devPath.c_str())); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 207 |  | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 208 | log<level::INFO>("Logging failing sysfs file", | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 209 | entry("FILE=%s", file.c_str())); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 210 | #ifdef REMOVE_ON_FAIL | 
| Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 211 | return {}; /* skip adding this sensor for now. */ | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 212 | #else | 
|  | 213 | exit(EXIT_FAILURE); | 
|  | 214 | #endif | 
|  | 215 | } | 
|  | 216 | auto sensorValue = valueInterface->value(); | 
| James Feist | ee73f5b | 2018-08-01 16:31:42 -0700 | [diff] [blame] | 217 | int64_t scale = 0; | 
|  | 218 | // scale the thresholds only if we're using doubles | 
|  | 219 | if constexpr (std::is_same<SensorValueType, double>::value) | 
|  | 220 | { | 
|  | 221 | scale = sensorObj->getScale(); | 
|  | 222 | } | 
|  | 223 | addThreshold<WarningObject>(sensor.first.first, | 
|  | 224 | std::get<sensorID>(properties), sensorValue, | 
|  | 225 | info, scale); | 
|  | 226 | addThreshold<CriticalObject>(sensor.first.first, | 
|  | 227 | std::get<sensorID>(properties), sensorValue, | 
|  | 228 | info, scale); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 229 |  | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 230 | auto target = | 
|  | 231 | addTarget<hwmon::FanSpeed>(sensor.first, ioAccess, _devPath, info); | 
| Matthew Barth | 28f8e66 | 2018-03-26 16:57:36 -0500 | [diff] [blame] | 232 | if (target) | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 233 | { | 
| Matthew Barth | 28f8e66 | 2018-03-26 16:57:36 -0500 | [diff] [blame] | 234 | target->enable(); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 235 | } | 
| Matthew Barth | 28f8e66 | 2018-03-26 16:57:36 -0500 | [diff] [blame] | 236 | addTarget<hwmon::FanPwm>(sensor.first, ioAccess, _devPath, info); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 237 |  | 
|  | 238 | // All the interfaces have been created.  Go ahead | 
|  | 239 | // and emit InterfacesAdded. | 
|  | 240 | valueInterface->emit_object_added(); | 
|  | 241 |  | 
| Matthew Barth | 9c43106 | 2018-05-07 13:55:29 -0500 | [diff] [blame] | 242 | // Save sensor object specifications | 
|  | 243 | sensorObjects[sensor.first] = std::move(sensorObj); | 
|  | 244 |  | 
| Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 245 | return std::make_pair(std::move(std::get<sensorLabel>(properties)), | 
|  | 246 | std::move(info)); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 247 | } | 
|  | 248 |  | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 249 | MainLoop::MainLoop(sdbusplus::bus::bus&& bus, const std::string& param, | 
|  | 250 | const std::string& path, const std::string& devPath, | 
|  | 251 | const char* prefix, const char* root) : | 
|  | 252 | _bus(std::move(bus)), | 
|  | 253 | _manager(_bus, root), _pathParam(param), _hwmonRoot(), _instance(), | 
| William A. Kennington III | 0fe4cb3 | 2018-10-18 19:19:58 -0700 | [diff] [blame] | 254 | _devPath(devPath), _prefix(prefix), _root(root), state(), ioAccess(path), | 
| William A. Kennington III | 0dd0c4d | 2018-10-18 19:20:01 -0700 | [diff] [blame] | 255 | event(sdeventplus::Event::get_default()), | 
|  | 256 | timer(event, std::bind(&MainLoop::read, this)) | 
| Brad Bishop | d499ca6 | 2016-12-19 09:24:50 -0500 | [diff] [blame] | 257 | { | 
| Patrick Venture | 73a50c7 | 2018-04-17 15:19:03 -0700 | [diff] [blame] | 258 | // Strip off any trailing slashes. | 
| Brad Bishop | b8740fc | 2017-02-24 23:38:37 -0500 | [diff] [blame] | 259 | std::string p = path; | 
|  | 260 | while (!p.empty() && p.back() == '/') | 
| Brad Bishop | 9c7b6e0 | 2016-12-19 12:43:36 -0500 | [diff] [blame] | 261 | { | 
| Brad Bishop | b8740fc | 2017-02-24 23:38:37 -0500 | [diff] [blame] | 262 | p.pop_back(); | 
| Brad Bishop | 9c7b6e0 | 2016-12-19 12:43:36 -0500 | [diff] [blame] | 263 | } | 
| Brad Bishop | b8740fc | 2017-02-24 23:38:37 -0500 | [diff] [blame] | 264 |  | 
| Patrick Venture | 73a50c7 | 2018-04-17 15:19:03 -0700 | [diff] [blame] | 265 | // Given the furthest right /, set instance to | 
|  | 266 | // the basename, and hwmonRoot to the leading path. | 
| Brad Bishop | b8740fc | 2017-02-24 23:38:37 -0500 | [diff] [blame] | 267 | auto n = p.rfind('/'); | 
|  | 268 | if (n != std::string::npos) | 
|  | 269 | { | 
|  | 270 | _instance.assign(p.substr(n + 1)); | 
|  | 271 | _hwmonRoot.assign(p.substr(0, n)); | 
|  | 272 | } | 
|  | 273 |  | 
|  | 274 | assert(!_instance.empty()); | 
|  | 275 | assert(!_hwmonRoot.empty()); | 
| Brad Bishop | d499ca6 | 2016-12-19 09:24:50 -0500 | [diff] [blame] | 276 | } | 
|  | 277 |  | 
|  | 278 | void MainLoop::shutdown() noexcept | 
|  | 279 | { | 
| William A. Kennington III | 0fe4cb3 | 2018-10-18 19:19:58 -0700 | [diff] [blame] | 280 | event.exit(0); | 
| Brad Bishop | d499ca6 | 2016-12-19 09:24:50 -0500 | [diff] [blame] | 281 | } | 
|  | 282 |  | 
|  | 283 | void MainLoop::run() | 
| Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 284 | { | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 285 | init(); | 
|  | 286 |  | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 287 | std::function<void()> callback(std::bind(&MainLoop::read, this)); | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 288 | try | 
|  | 289 | { | 
| William A. Kennington III | 0dd0c4d | 2018-10-18 19:20:01 -0700 | [diff] [blame] | 290 | timer.restart(std::chrono::microseconds(_interval)); | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 291 |  | 
|  | 292 | // TODO: Issue#6 - Optionally look at polling interval sysfs entry. | 
|  | 293 |  | 
|  | 294 | // TODO: Issue#7 - Should probably periodically check the SensorSet | 
|  | 295 | //       for new entries. | 
|  | 296 |  | 
| William A. Kennington III | 0fe4cb3 | 2018-10-18 19:19:58 -0700 | [diff] [blame] | 297 | _bus.attach_event(event.get(), SD_EVENT_PRIORITY_IMPORTANT); | 
|  | 298 | event.loop(); | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 299 | } | 
| William A. Kennington III | 0fe4cb3 | 2018-10-18 19:19:58 -0700 | [diff] [blame] | 300 | catch (const std::exception& e) | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 301 | { | 
|  | 302 | log<level::ERR>("Error in sysfs polling loop", | 
|  | 303 | entry("ERROR=%s", e.what())); | 
|  | 304 | throw; | 
|  | 305 | } | 
|  | 306 | } | 
|  | 307 |  | 
|  | 308 | void MainLoop::init() | 
|  | 309 | { | 
| Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 310 | // Check sysfs for available sensors. | 
| Brad Bishop | 4db6442 | 2017-02-16 11:33:32 -0500 | [diff] [blame] | 311 | auto sensors = std::make_unique<SensorSet>(_hwmonRoot + '/' + _instance); | 
| Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 312 |  | 
| Patrick Venture | db7ecb6 | 2018-10-23 19:42:23 -0700 | [diff] [blame^] | 313 | for (const auto& i : *sensors) | 
| Brad Bishop | 75b4ab8 | 2017-01-06 09:33:50 -0500 | [diff] [blame] | 314 | { | 
| Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 315 | auto object = getObject(i); | 
|  | 316 | if (object) | 
|  | 317 | { | 
|  | 318 | // Construct the SensorSet value | 
|  | 319 | // std::tuple<SensorSet::mapped_type, | 
|  | 320 | //            std::string(Sensor Label), | 
|  | 321 | //            ObjectInfo> | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 322 | auto value = | 
|  | 323 | std::make_tuple(std::move(i.second), std::move((*object).first), | 
|  | 324 | std::move((*object).second)); | 
| Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 325 |  | 
|  | 326 | state[std::move(i.first)] = std::move(value); | 
|  | 327 | } | 
| Brad Bishop | 75b4ab8 | 2017-01-06 09:33:50 -0500 | [diff] [blame] | 328 | } | 
|  | 329 |  | 
| Patrick Venture | 62503a4 | 2017-05-23 07:30:29 -0700 | [diff] [blame] | 330 | /* If there are no sensors specified by labels, exit. */ | 
|  | 331 | if (0 == state.size()) | 
|  | 332 | { | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 333 | exit(0); | 
| Patrick Venture | 62503a4 | 2017-05-23 07:30:29 -0700 | [diff] [blame] | 334 | } | 
|  | 335 |  | 
| Brad Bishop | 9c7b6e0 | 2016-12-19 12:43:36 -0500 | [diff] [blame] | 336 | { | 
| Patrick Venture | c897d8b | 2018-04-23 19:01:56 -0700 | [diff] [blame] | 337 | std::stringstream ss; | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 338 | ss << _prefix << "-" | 
| Patrick Venture | c897d8b | 2018-04-23 19:01:56 -0700 | [diff] [blame] | 339 | << std::to_string(std::hash<std::string>{}(_devPath + _pathParam)) | 
|  | 340 | << ".Hwmon1"; | 
|  | 341 |  | 
|  | 342 | _bus.request_name(ss.str().c_str()); | 
| Brad Bishop | 9c7b6e0 | 2016-12-19 12:43:36 -0500 | [diff] [blame] | 343 | } | 
|  | 344 |  | 
| Patrick Venture | ab10f16 | 2017-05-22 09:44:50 -0700 | [diff] [blame] | 345 | { | 
| Patrick Venture | a24c880 | 2018-04-17 19:38:06 -0700 | [diff] [blame] | 346 | auto interval = env::getEnv("INTERVAL"); | 
|  | 347 | if (!interval.empty()) | 
| Patrick Venture | ab10f16 | 2017-05-22 09:44:50 -0700 | [diff] [blame] | 348 | { | 
| Patrick Venture | 50cf1c5 | 2018-04-18 09:21:41 -0700 | [diff] [blame] | 349 | _interval = std::strtoull(interval.c_str(), NULL, 10); | 
| Patrick Venture | ab10f16 | 2017-05-22 09:44:50 -0700 | [diff] [blame] | 350 | } | 
|  | 351 | } | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 352 | } | 
| Patrick Venture | ab10f16 | 2017-05-22 09:44:50 -0700 | [diff] [blame] | 353 |  | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 354 | void MainLoop::read() | 
|  | 355 | { | 
| Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 356 | // TODO: Issue#3 - Need to make calls to the dbus sensor cache here to | 
|  | 357 | //       ensure the objects all exist? | 
|  | 358 |  | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 359 | // Iterate through all the sensors. | 
|  | 360 | for (auto& i : state) | 
|  | 361 | { | 
|  | 362 | auto& attrs = std::get<0>(i.second); | 
|  | 363 | if (attrs.find(hwmon::entry::input) != attrs.end()) | 
| Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 364 | { | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 365 | // Read value from sensor. | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 366 | std::string input = hwmon::entry::cinput; | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 367 | if (i.first.first == "pwm") | 
|  | 368 | { | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 369 | input = ""; | 
|  | 370 | } | 
|  | 371 |  | 
|  | 372 | try | 
| Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 373 | { | 
| Patrick Venture | 685efa1 | 2018-10-12 18:00:13 -0700 | [diff] [blame] | 374 | int64_t value; | 
| Matthew Barth | 27c4a39 | 2018-04-25 14:38:51 -0500 | [diff] [blame] | 375 | auto& objInfo = std::get<ObjectInfo>(i.second); | 
|  | 376 | auto& obj = std::get<Object>(objInfo); | 
|  | 377 |  | 
|  | 378 | auto it = obj.find(InterfaceType::STATUS); | 
|  | 379 | if (it != obj.end()) | 
|  | 380 | { | 
| Matthew Barth | bfcaf3d | 2018-04-25 15:05:58 -0500 | [diff] [blame] | 381 | auto fault = ioAccess.read( | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 382 | i.first.first, i.first.second, hwmon::entry::fault, | 
|  | 383 | hwmonio::retries, hwmonio::delay); | 
| William A. Kennington III | 4cbdfef | 2018-10-18 19:19:51 -0700 | [diff] [blame] | 384 | auto statusIface = | 
|  | 385 | std::any_cast<std::shared_ptr<StatusObject>>( | 
|  | 386 | it->second); | 
| Matthew Barth | bfcaf3d | 2018-04-25 15:05:58 -0500 | [diff] [blame] | 387 | if (!statusIface->functional((fault == 0) ? true : false)) | 
| Matthew Barth | 27c4a39 | 2018-04-25 14:38:51 -0500 | [diff] [blame] | 388 | { | 
|  | 389 | continue; | 
|  | 390 | } | 
|  | 391 | } | 
|  | 392 |  | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 393 | // Retry for up to a second if device is busy | 
|  | 394 | // or has a transient error. | 
| Patrick Venture | b28f432 | 2018-09-14 10:19:14 -0700 | [diff] [blame] | 395 | std::unique_ptr<sensor::Sensor>& sensor = | 
|  | 396 | sensorObjects[i.first]; | 
|  | 397 |  | 
|  | 398 | sensor->unlockGpio(); | 
| Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 399 |  | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 400 | value = ioAccess.read(i.first.first, i.first.second, input, | 
|  | 401 | hwmonio::retries, hwmonio::delay); | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 402 |  | 
| Patrick Venture | b28f432 | 2018-09-14 10:19:14 -0700 | [diff] [blame] | 403 | sensor->lockGpio(); | 
|  | 404 |  | 
|  | 405 | value = sensor->adjustValue(value); | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 406 |  | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 407 | for (auto& iface : obj) | 
| Brad Bishop | dddb715 | 2017-01-06 09:54:23 -0500 | [diff] [blame] | 408 | { | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 409 | auto valueIface = std::shared_ptr<ValueObject>(); | 
|  | 410 | auto warnIface = std::shared_ptr<WarningObject>(); | 
|  | 411 | auto critIface = std::shared_ptr<CriticalObject>(); | 
| Brad Bishop | 754d38c | 2017-09-08 00:46:58 -0400 | [diff] [blame] | 412 |  | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 413 | switch (iface.first) | 
| Brad Bishop | e0b7d05 | 2017-01-06 15:30:23 -0500 | [diff] [blame] | 414 | { | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 415 | case InterfaceType::VALUE: | 
| William A. Kennington III | 4cbdfef | 2018-10-18 19:19:51 -0700 | [diff] [blame] | 416 | valueIface = | 
|  | 417 | std::any_cast<std::shared_ptr<ValueObject>>( | 
|  | 418 | iface.second); | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 419 | valueIface->value(value); | 
|  | 420 | break; | 
|  | 421 | case InterfaceType::WARN: | 
|  | 422 | checkThresholds<WarningObject>(iface.second, value); | 
|  | 423 | break; | 
|  | 424 | case InterfaceType::CRIT: | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 425 | checkThresholds<CriticalObject>(iface.second, | 
|  | 426 | value); | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 427 | break; | 
|  | 428 | default: | 
|  | 429 | break; | 
| Brad Bishop | e0b7d05 | 2017-01-06 15:30:23 -0500 | [diff] [blame] | 430 | } | 
| Brad Bishop | dddb715 | 2017-01-06 09:54:23 -0500 | [diff] [blame] | 431 | } | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 432 | } | 
|  | 433 | catch (const std::system_error& e) | 
|  | 434 | { | 
| Matthew Barth | 38c74e7 | 2018-04-02 12:41:26 -0500 | [diff] [blame] | 435 | auto file = sysfs::make_sysfs_path( | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 436 | ioAccess.path(), i.first.first, i.first.second, | 
|  | 437 | hwmon::entry::cinput); | 
| Matthew Barth | 8772ce3 | 2018-03-22 16:03:06 -0500 | [diff] [blame] | 438 | #ifndef REMOVE_ON_FAIL | 
|  | 439 | // Check sensorAdjusts for sensor removal RCs | 
| Matthew Barth | ac47309 | 2018-05-07 14:41:46 -0500 | [diff] [blame] | 440 | auto& sAdjusts = sensorObjects[i.first]->getAdjusts(); | 
|  | 441 | if (sAdjusts.rmRCs.count(e.code().value()) > 0) | 
| Matthew Barth | 8772ce3 | 2018-03-22 16:03:06 -0500 | [diff] [blame] | 442 | { | 
| Matthew Barth | ac47309 | 2018-05-07 14:41:46 -0500 | [diff] [blame] | 443 | // Return code found in sensor return code removal list | 
|  | 444 | if (rmSensors.find(i.first) == rmSensors.end()) | 
| Matthew Barth | 8772ce3 | 2018-03-22 16:03:06 -0500 | [diff] [blame] | 445 | { | 
| Matthew Barth | ac47309 | 2018-05-07 14:41:46 -0500 | [diff] [blame] | 446 | // Trace for sensor not already removed from dbus | 
|  | 447 | log<level::INFO>( | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 448 | "Remove sensor from dbus for read fail", | 
|  | 449 | entry("FILE=%s", file.c_str()), | 
|  | 450 | entry("RC=%d", e.code().value())); | 
| Matthew Barth | ac47309 | 2018-05-07 14:41:46 -0500 | [diff] [blame] | 451 | // Mark this sensor to be removed from dbus | 
|  | 452 | rmSensors[i.first] = std::get<0>(i.second); | 
| Matthew Barth | 8772ce3 | 2018-03-22 16:03:06 -0500 | [diff] [blame] | 453 | } | 
| Matthew Barth | ac47309 | 2018-05-07 14:41:46 -0500 | [diff] [blame] | 454 | continue; | 
| Matthew Barth | 8772ce3 | 2018-03-22 16:03:06 -0500 | [diff] [blame] | 455 | } | 
|  | 456 | #endif | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 457 | using namespace sdbusplus::xyz::openbmc_project::Sensor:: | 
|  | 458 | Device::Error; | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 459 | report<ReadFailure>( | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 460 | xyz::openbmc_project::Sensor::Device::ReadFailure:: | 
|  | 461 | CALLOUT_ERRNO(e.code().value()), | 
|  | 462 | xyz::openbmc_project::Sensor::Device::ReadFailure:: | 
|  | 463 | CALLOUT_DEVICE_PATH(_devPath.c_str())); | 
| Matt Spinler | 9b65f76 | 2017-10-05 10:36:22 -0500 | [diff] [blame] | 464 |  | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 465 | log<level::INFO>("Logging failing sysfs file", | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 466 | entry("FILE=%s", file.c_str())); | 
| Matt Spinler | 9b65f76 | 2017-10-05 10:36:22 -0500 | [diff] [blame] | 467 |  | 
| Matt Spinler | f9c83c4 | 2017-08-10 08:51:45 -0500 | [diff] [blame] | 468 | #ifdef REMOVE_ON_FAIL | 
| Matthew Barth | 33db92b | 2018-03-26 09:55:19 -0500 | [diff] [blame] | 469 | rmSensors[i.first] = std::get<0>(i.second); | 
| Matt Spinler | f9c83c4 | 2017-08-10 08:51:45 -0500 | [diff] [blame] | 470 | #else | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 471 | exit(EXIT_FAILURE); | 
| Matt Spinler | f9c83c4 | 2017-08-10 08:51:45 -0500 | [diff] [blame] | 472 | #endif | 
| Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 473 | } | 
|  | 474 | } | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 475 | } | 
| Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 476 |  | 
| Matthew Barth | 8772ce3 | 2018-03-22 16:03:06 -0500 | [diff] [blame] | 477 | // Remove any sensors marked for removal | 
| Patrick Venture | db7ecb6 | 2018-10-23 19:42:23 -0700 | [diff] [blame^] | 478 | for (const auto& i : rmSensors) | 
| Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 479 | { | 
| Matthew Barth | 33db92b | 2018-03-26 09:55:19 -0500 | [diff] [blame] | 480 | state.erase(i.first); | 
| Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 481 | } | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 482 |  | 
|  | 483 | #ifndef REMOVE_ON_FAIL | 
|  | 484 | // Attempt to add any sensors that were removed | 
|  | 485 | auto it = rmSensors.begin(); | 
|  | 486 | while (it != rmSensors.end()) | 
|  | 487 | { | 
|  | 488 | if (state.find(it->first) == state.end()) | 
|  | 489 | { | 
|  | 490 | SensorSet::container_t::value_type ssValueType = | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 491 | std::make_pair(it->first, it->second); | 
| Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 492 | auto object = getObject(ssValueType); | 
|  | 493 | if (object) | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 494 | { | 
| Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 495 | // Construct the SensorSet value | 
|  | 496 | // std::tuple<SensorSet::mapped_type, | 
|  | 497 | //            std::string(Sensor Label), | 
|  | 498 | //            ObjectInfo> | 
|  | 499 | auto value = std::make_tuple(std::move(ssValueType.second), | 
|  | 500 | std::move((*object).first), | 
|  | 501 | std::move((*object).second)); | 
|  | 502 |  | 
|  | 503 | state[std::move(ssValueType.first)] = std::move(value); | 
|  | 504 |  | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 505 | // Sensor object added, erase entry from removal list | 
| Matthew Barth | 38c74e7 | 2018-04-02 12:41:26 -0500 | [diff] [blame] | 506 | auto file = sysfs::make_sysfs_path( | 
| Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 507 | ioAccess.path(), it->first.first, it->first.second, | 
|  | 508 | hwmon::entry::cinput); | 
|  | 509 | log<level::INFO>("Added sensor to dbus after successful read", | 
|  | 510 | entry("FILE=%s", file.c_str())); | 
| Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 511 | it = rmSensors.erase(it); | 
|  | 512 | } | 
|  | 513 | else | 
|  | 514 | { | 
|  | 515 | ++it; | 
|  | 516 | } | 
|  | 517 | } | 
|  | 518 | else | 
|  | 519 | { | 
|  | 520 | // Sanity check to remove sensors that were re-added | 
|  | 521 | it = rmSensors.erase(it); | 
|  | 522 | } | 
|  | 523 | } | 
|  | 524 | #endif | 
| Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 525 | } | 
|  | 526 |  | 
|  | 527 | // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 |