summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2017-10-12 16:44:53 -0500
committerMatt Spinler <spinler@us.ibm.com>2017-10-17 10:03:10 -0500
commit4b68c4eebdfaecf2bb7530fdf3ca009ad0ddfc40 (patch)
tree1412525c30ee1c7fdccc90181b50279d0d5accdb
parenta3eb8e3f0039a51fd679db694db16694ef362e47 (diff)
downloadphosphor-hwmon-4b68c4eebdfaecf2bb7530fdf3ca009ad0ddfc40.tar.gz
phosphor-hwmon-4b68c4eebdfaecf2bb7530fdf3ca009ad0ddfc40.zip
Refactor method of looking up indirect labels
Use a combination of getIndirectID() and getEnv() when looking up labels when their values are specified in sysfs files instead of getIndirectLabelEnv(). This is done so the ID is exposed and can be used later for looking up thresholds. Change-Id: I4d2399bb7717130e61a8aacc37e75f36f410c94e Signed-off-by: Matt Spinler <spinler@us.ibm.com>
-rw-r--r--mainloop.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/mainloop.cpp b/mainloop.cpp
index 6291813..3205ad8 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -286,33 +286,37 @@ void MainLoop::run()
for (auto& i : *sensors)
{
std::string label;
+ std::string id;
/*
* Check if the value of the MODE_<item><X> env variable for the sensor
* is "label", then read the sensor number from the <item><X>_label
* file. The name of the DBUS object would be the value of the env
* variable LABEL_<item><sensorNum>. If the MODE_<item><X> env variable
- * does'nt exist, then the name of DBUS object is the value of the env
+ * doesn't exist, then the name of DBUS object is the value of the env
* variable LABEL_<item><X>.
*/
auto mode = getEnv("MODE", i.first);
if (!mode.compare(hwmon::entry::label))
{
- label = getIndirectLabelEnv(
- "LABEL", _hwmonRoot + '/' + _instance + '/', i.first);
- if (label.empty())
+ id = getIndirectID(
+ _hwmonRoot + '/' + _instance + '/', i.first);
+
+ if (id.empty())
{
continue;
}
}
- else
+
+ //In this loop, use the ID we looked up above if
+ //there was one, otherwise use the standard one.
+ id = (id.empty()) ? i.first.second : id;
+
+ // Ignore inputs without a label.
+ label = getEnv("LABEL", i.first.first, id);
+ if (label.empty())
{
- // Ignore inputs without a label.
- label = getEnv("LABEL", i.first);
- if (label.empty())
- {
- continue;
- }
+ continue;
}
Attributes attrs;
OpenPOWER on IntegriCloud