HwmonTempMain: revert the type of bus and address back to uint64_t

In I546e967abae7c0fb9fca645867e3037046037647, the type of bus and
address in HwmonTempMain were updated to size_t.

However, in some systems using i3c, the device name is composed by bus
number and the provisioned ID [1]. The provisioned ID is a 48-bit value
(MIPI I3C Basic, v1.1.1, section 5.1.4.1.1), which is greater than the
range of size_t on e.g. 32-bit ARM platforms. Thus, reverting the type
back to uint64_t.

[1] Linux in-turn uses this Provisioned ID to identify the device, and
exposes the Provisioned ID in the device name:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i3c/master.c?h=v6.6#n1521

Tested:
- added unit test passed.
- can read temperature of the i3c devices from our system.

Change-Id: I6f0e73aaf5f8d28e4bdedbe85646373463f6707f
Signed-off-by: Tom Tung <shes050117@gmail.com>
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index b44eb9d..8531776 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -302,8 +302,8 @@
                 deviceName = fs::canonical(device).stem();
             }
 
-            size_t bus = 0;
-            size_t addr = 0;
+            uint64_t bus = 0;
+            uint64_t addr = 0;
             if (!getDeviceBusAddr(deviceName, bus, addr))
             {
                 continue;
diff --git a/src/Utils.cpp b/src/Utils.cpp
index 94bf614..357d143 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -850,31 +850,3 @@
     }
     return setupPropertiesChangedMatches(bus, {types}, handler);
 }
-
-bool getDeviceBusAddr(const std::string& deviceName, size_t& bus, size_t& addr)
-{
-    auto findHyphen = deviceName.find('-');
-    if (findHyphen == std::string::npos)
-    {
-        std::cerr << "found bad device " << deviceName << "\n";
-        return false;
-    }
-    std::string busStr = deviceName.substr(0, findHyphen);
-    std::string addrStr = deviceName.substr(findHyphen + 1);
-
-    std::from_chars_result res{};
-    res = std::from_chars(&*busStr.begin(), &*busStr.end(), bus);
-    if (res.ec != std::errc{} || res.ptr != &*busStr.end())
-    {
-        std::cerr << "Error finding bus for " << deviceName << "\n";
-        return false;
-    }
-    res = std::from_chars(&*addrStr.begin(), &*addrStr.end(), addr, 16);
-    if (res.ec != std::errc{} || res.ptr != &*addrStr.end())
-    {
-        std::cerr << "Error finding addr for " << deviceName << "\n";
-        return false;
-    }
-
-    return true;
-}
diff --git a/src/Utils.hpp b/src/Utils.hpp
index 2438e4f..4562b6f 100644
--- a/src/Utils.hpp
+++ b/src/Utils.hpp
@@ -387,4 +387,32 @@
     setupPropertiesChangedMatches(
         sdbusplus::asio::connection& bus, std::span<const char* const> types,
         const std::function<void(sdbusplus::message_t&)>& handler);
-bool getDeviceBusAddr(const std::string& deviceName, size_t& bus, size_t& addr);
+
+template <typename T>
+bool getDeviceBusAddr(const std::string& deviceName, T& bus, T& addr)
+{
+    auto findHyphen = deviceName.find('-');
+    if (findHyphen == std::string::npos)
+    {
+        std::cerr << "found bad device " << deviceName << "\n";
+        return false;
+    }
+    std::string busStr = deviceName.substr(0, findHyphen);
+    std::string addrStr = deviceName.substr(findHyphen + 1);
+
+    std::from_chars_result res{};
+    res = std::from_chars(&*busStr.begin(), &*busStr.end(), bus);
+    if (res.ec != std::errc{} || res.ptr != &*busStr.end())
+    {
+        std::cerr << "Error finding bus for " << deviceName << "\n";
+        return false;
+    }
+    res = std::from_chars(&*addrStr.begin(), &*addrStr.end(), addr, 16);
+    if (res.ec != std::errc{} || res.ptr != &*addrStr.end())
+    {
+        std::cerr << "Error finding addr for " << deviceName << "\n";
+        return false;
+    }
+
+    return true;
+}
diff --git a/tests/test_Utils.cpp b/tests/test_Utils.cpp
index 67fc3a5..59a4e13 100644
--- a/tests/test_Utils.cpp
+++ b/tests/test_Utils.cpp
@@ -212,6 +212,18 @@
     EXPECT_FALSE(ret);
 }
 
+TEST(GetDeviceBusAddrTest, I3CBusAddrValid)
+{
+    uint64_t bus = 0;
+    uint64_t provisionedId = 0;
+    std::string devName = "0-22400000001";
+
+    auto ret = getDeviceBusAddr(devName, bus, provisionedId);
+    EXPECT_TRUE(ret);
+    EXPECT_EQ(bus, 0);
+    EXPECT_EQ(provisionedId, 0x22400000001);
+}
+
 TEST(GetDeviceBusAddrTest, AllValid)
 {
     size_t bus = 0;