diff options
author | Patrick Venture <venture@google.com> | 2018-04-17 19:15:05 -0700 |
---|---|---|
committer | Patrick Venture <venture@google.com> | 2018-04-18 14:06:11 -0700 |
commit | 7a5285de708b2f46d47f37920c784314b4ad55aa (patch) | |
tree | 08750f56b723c88d653a1d6f963645784667e5d6 | |
parent | 73a50c7f1cd02fca7cbc69e6304514157c59fa63 (diff) | |
download | phosphor-hwmon-7a5285de708b2f46d47f37920c784314b4ad55aa.tar.gz phosphor-hwmon-7a5285de708b2f46d47f37920c784314b4ad55aa.zip |
move getEnv methods into env namespace
Move the getEnv(...) methods into the env namespace,
for consistency.
Change-Id: I4055d9456c17f8b20071cdee1b8e531c10fb0c7e
Signed-off-by: Patrick Venture <venture@google.com>
-rw-r--r-- | env.cpp | 4 | ||||
-rw-r--r-- | env.hpp | 4 | ||||
-rw-r--r-- | fan_speed.cpp | 2 | ||||
-rw-r--r-- | mainloop.cpp | 16 | ||||
-rw-r--r-- | targets.hpp | 3 | ||||
-rw-r--r-- | thresholds.hpp | 6 |
6 files changed, 23 insertions, 12 deletions
@@ -20,6 +20,8 @@ #include "env.hpp" #include "hwmon.hpp" +namespace env { + std::string getEnv( const char* prefix, const SensorSet::key_type& sensor) { @@ -76,4 +78,6 @@ std::string getIndirectID( return content; } +} // namespace env + // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 @@ -4,6 +4,8 @@ #include "sensorset.hpp" +namespace env { + /** @brief Reads an environment variable * * Reads <prefix>_<sensor.first><sensor.second> @@ -40,3 +42,5 @@ std::string getEnv( std::string getIndirectID( std::string path, const SensorSet::key_type& sensor); + +} // namespace env diff --git a/fan_speed.cpp b/fan_speed.cpp index 2652f8d..15ce946 100644 --- a/fan_speed.cpp +++ b/fan_speed.cpp @@ -58,7 +58,7 @@ uint64_t FanSpeed::target(uint64_t value) void FanSpeed::enable() { - auto enable = getEnv("ENABLE", type, id); + auto enable = env::getEnv("ENABLE", type, id); if (!enable.empty()) { auto val = std::stoul(enable); diff --git a/mainloop.cpp b/mainloop.cpp index 62467fd..99c8020 100644 --- a/mainloop.cpp +++ b/mainloop.cpp @@ -219,7 +219,7 @@ auto addValue(const SensorSet::key_type& sensor, auto& obj = std::get<Object>(info); auto& objPath = std::get<std::string>(info); - auto senRmRCs = getEnv("REMOVERCS", sensor); + auto senRmRCs = env::getEnv("REMOVERCS", sensor); if (!senRmRCs.empty()) { // Add sensor removal return codes defined per sensor @@ -236,13 +236,13 @@ auto addValue(const SensorSet::key_type& sensor, std::get<std::chrono::milliseconds>(retryIO), isOCC); - auto gain = getEnv("GAIN", sensor); + auto gain = env::getEnv("GAIN", sensor); if (!gain.empty()) { sensorAdjusts[sensor].gain = std::stod(gain); } - auto offset = getEnv("OFFSET", sensor); + auto offset = env::getEnv("OFFSET", sensor); if (!offset.empty()) { sensorAdjusts[sensor].offset = std::stoi(offset); @@ -260,12 +260,12 @@ auto addValue(const SensorSet::key_type& sensor, iface->scale(getScale(attrs)); } - auto maxValue = getEnv("MAXVALUE", sensor); + auto maxValue = env::getEnv("MAXVALUE", sensor); if(!maxValue.empty()) { iface->maxValue(std::stoll(maxValue)); } - auto minValue = getEnv("MINVALUE", sensor); + auto minValue = env::getEnv("MINVALUE", sensor); if(!minValue.empty()) { iface->minValue(std::stoll(minValue)); @@ -304,10 +304,10 @@ void MainLoop::getObject(SensorSet::container_t::const_reference sensor) * doesn't exist, then the name of DBUS object is the value of the env * variable LABEL_<item><X>. */ - auto mode = getEnv("MODE", sensor.first); + auto mode = env::getEnv("MODE", sensor.first); if (!mode.compare(hwmon::entry::label)) { - id = getIndirectID( + id = env::getIndirectID( _hwmonRoot + '/' + _instance + '/', sensor.first); if (id.empty()) @@ -321,7 +321,7 @@ void MainLoop::getObject(SensorSet::container_t::const_reference sensor) id = (id.empty()) ? sensor.first.second : id; // Ignore inputs without a label. - label = getEnv("LABEL", sensor.first.first, id); + label = env::getEnv("LABEL", sensor.first.first, id); if (label.empty()) { return; diff --git a/targets.hpp b/targets.hpp index 3c6dc0d..fe256a3 100644 --- a/targets.hpp +++ b/targets.hpp @@ -4,6 +4,7 @@ #include <phosphor-logging/elog-errors.hpp> #include <phosphor-logging/log.hpp> #include <xyz/openbmc_project/Sensor/Device/error.hpp> +#include "env.hpp" #include "fan_speed.hpp" #include "fan_pwm.hpp" @@ -87,7 +88,7 @@ std::shared_ptr<T> addTarget(const SensorSet::key_type& sensor, { targetName = pwm; // If PWM_TARGET is set, use the specified pwm id - auto id = getEnv("PWM_TARGET", sensor); + auto id = env::getEnv("PWM_TARGET", sensor); if (!id.empty()) { targetId = id; diff --git a/thresholds.hpp b/thresholds.hpp index 96d4b75..684e712 100644 --- a/thresholds.hpp +++ b/thresholds.hpp @@ -1,5 +1,7 @@ #pragma once +#include "env.hpp" + /** @class Thresholds * @brief Threshold type traits. * @@ -90,8 +92,8 @@ auto addThreshold(const std::string& sensorType, auto& obj = std::get<Object>(info); std::shared_ptr<T> iface; - auto tLo = getEnv(Thresholds<T>::envLo, sensorType, sensorID); - auto tHi = getEnv(Thresholds<T>::envHi, sensorType, sensorID); + auto tLo = env::getEnv(Thresholds<T>::envLo, sensorType, sensorID); + auto tHi = env::getEnv(Thresholds<T>::envHi, sensorType, sensorID); if (!tLo.empty() && !tHi.empty()) { iface = std::make_shared<T>(bus, objPath.c_str(), deferSignals); |