mainloop: add uniqueness to busname

There can be multiple daemon instances that have the
same devpath which leads to a collision which errors silently.
This adds uniqueness to the path, which was no longer human-readable
to avoid this collision situation.

Tested: Ran on quanta-q71l with unique devices and two instances
pointing to the same device and it correctly set them up with unique
but deterministic bus names.
Change-Id: Id5aea3c3df5f793b28557a74995608ec40792a43
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/mainloop.cpp b/mainloop.cpp
index bfc010e..221c8c9 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -20,6 +20,7 @@
 #include <cstring>
 #include <string>
 #include <unordered_set>
+#include <sstream>
 
 #include <phosphor-logging/elog-errors.hpp>
 #include "config.h"
@@ -380,12 +381,14 @@
 
 MainLoop::MainLoop(
     sdbusplus::bus::bus&& bus,
+    const std::string& param,
     const std::string& path,
     const std::string& devPath,
     const char* prefix,
     const char* root)
     : _bus(std::move(bus)),
       _manager(_bus, root),
+      _pathParam(param),
       _hwmonRoot(),
       _instance(),
       _devPath(devPath),
@@ -481,12 +484,13 @@
     }
 
     {
-        std::string busname{_prefix};
-        busname.append(1, '-');
-        busname.append(
-                std::to_string(std::hash<decltype(_devPath)>{}(_devPath)));
-        busname.append(".Hwmon1");
-        _bus.request_name(busname.c_str());
+        std::stringstream ss;
+        ss << _prefix
+           << "-"
+           << std::to_string(std::hash<std::string>{}(_devPath + _pathParam))
+           << ".Hwmon1";
+
+        _bus.request_name(ss.str().c_str());
     }
 
     {