summaryrefslogtreecommitdiffstats
path: root/controller.cpp
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-03-30 17:25:18 +0530
committerVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-03-31 11:11:10 +0530
commit413fd348514e5ab779a445f4f2cee84e9254b9a1 (patch)
tree4967ea17c574f34a624ab1a5697f5337ef8bbf1a /controller.cpp
parente089173fac7240173b227ac61d32fdf2ef367a83 (diff)
downloadphosphor-led-sysfs-413fd348514e5ab779a445f4f2cee84e9254b9a1.tar.gz
phosphor-led-sysfs-413fd348514e5ab779a445f4f2cee84e9254b9a1.zip
LEDS: Handle physical LED names containing hyphen
It is possible that LED names can contain hyphen(s) in them making it inappropriate for announcing the name on dbus. Fix would be to convert the hyphen to underscores just for announcing on dbus while using the actual name for rest everything. Fixes openbmc/openbmc#802 Change-Id: Ia916786e9abf948970b36242f57c27aa90d4a962 Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
Diffstat (limited to 'controller.cpp')
-rw-r--r--controller.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/controller.cpp b/controller.cpp
index 4e83f58..d5728da 100644
--- a/controller.cpp
+++ b/controller.cpp
@@ -16,6 +16,7 @@
#include <iostream>
#include <string>
+#include <algorithm>
#include "argument.hpp"
#include "physical.hpp"
#include "config.h"
@@ -50,6 +51,14 @@ int main(int argc, char** argv)
// Remove the leading "/"
auto name = path.substr(index + 1);
+ // Convert to lowercase just in case some are not and that
+ // we follow lowercase all over
+ std::transform(name.begin(), name.end(), name.begin(), ::tolower);
+
+ // LED names may have a hyphen and that would be an issue for
+ // dbus paths and hence need to convert them to underscores.
+ std::replace(name.begin(), name.end(), '-', '_');
+
// Unique bus name representing a single LED.
auto busName = std::string(BUSNAME) + '.' + name;
auto objPath = std::string(OBJPATH) + '/' + name;
OpenPOWER on IntegriCloud