summaryrefslogtreecommitdiffstats
path: root/mainloop.cpp
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2017-06-12 20:10:59 +0530
committerPatrick Williams <patrick@stwcx.xyz>2017-06-14 07:19:02 +0000
commit1f8a9586266d90f8d88b5c1af51833b067d9c0b8 (patch)
tree99d6bc5b1468c10228a6394b73838bf3db7fbfef /mainloop.cpp
parent8af8a2002f54178c64d59c86a8abe57bd3787b56 (diff)
downloadphosphor-hwmon-1f8a9586266d90f8d88b5c1af51833b067d9c0b8.tar.gz
phosphor-hwmon-1f8a9586266d90f8d88b5c1af51833b067d9c0b8.zip
Add a level of indirection when naming the DBUS objects
The current design ignores the itemX_label sysfs attribute, if the environment variable is populated with the MODE_itemX="label", then fetch the label from itemX_label file.The actual label for the dbus object is fetched from the environment variable LABEL_item<label>. Resolves openbmc/openbmc#1633 Change-Id: I0d4baaa91073dd5db75ac62277d78ad9b3065e64 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Diffstat (limited to 'mainloop.cpp')
-rw-r--r--mainloop.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/mainloop.cpp b/mainloop.cpp
index 1da6b69..5976307 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -212,13 +212,34 @@ void MainLoop::run()
for (auto& i : *sensors)
{
- // Get sensor configuration from the environment.
-
- // Ignore inputs without a label.
- auto label = getEnv("LABEL", i.first);
- if (label.empty())
+ std::string label;
+
+ /*
+ * 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
+ * variable LABEL_<item><X>.
+ */
+ auto mode = getEnv("MODE", i.first);
+ if (!mode.compare(hwmon::entry::label))
{
- continue;
+ label = getIndirectLabelEnv(
+ "LABEL", _hwmonRoot + '/' + _instance + '/', i.first);
+ if (label.empty())
+ {
+ continue;
+ }
+ }
+ else
+ {
+ // Ignore inputs without a label.
+ label = getEnv("LABEL", i.first);
+ if (label.empty())
+ {
+ continue;
+ }
}
Attributes attrs;
OpenPOWER on IntegriCloud