summaryrefslogtreecommitdiffstats
path: root/monitor/fan.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'monitor/fan.cpp')
-rw-r--r--monitor/fan.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 014080d..6df98e5 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -36,7 +36,8 @@ Fan::Fan(Mode mode,
const FanDefinition& def) :
_bus(bus),
_name(std::get<fanNameField>(def)),
- _deviation(std::get<fanDeviationField>(def)),
+ _deviation((std::get<fanDeviationField>(def) < 0)?abs(std::get<fanDeviationField>(def)):std::get<fanDeviationField>(def)),
+ _deviationIsMinRPM((std::get<fanDeviationField>(def) < 0)?true:false),
_numSensorFailsForNonFunc(std::get<numSensorFailsForNonfuncField>(def)),
_trustManager(trust)
{
@@ -168,17 +169,26 @@ bool Fan::outOfRange(const TachSensor& sensor)
auto factor = sensor.getFactor();
auto offset = sensor.getOffset();
- uint64_t min = target * (100 - _deviation) / 100;
- uint64_t max = target * (100 + _deviation) / 100;
-
- // TODO: openbmc/openbmc#2937 enhance this function
- // either by making it virtual, or by predefining different
- // outOfRange ops and selecting by yaml config
- min = min * factor + offset;
- max = max * factor + offset;
- if ((actual < min) || (actual > max))
+ if (_deviationIsMinRPM)
{
- return true;
+ if (actual < _deviation)
+ {
+ return true;
+ }
+ }
+ else {
+ uint64_t min = target * (100 - _deviation) / 100;
+ uint64_t max = target * (100 + _deviation) / 100;
+
+ // TODO: openbmc/openbmc#2937 enhance this function
+ // either by making it virtual, or by predefining different
+ // outOfRange ops and selecting by yaml config
+ min = min * factor + offset;
+ max = max * factor + offset;
+ if ((actual < min) || (actual > max))
+ {
+ return true;
+ }
}
return false;
OpenPOWER on IntegriCloud