PLDM:Use new alias of DBUS_TIMEOUT for bus.call

This commit uses a new global variable for DBUS_TIMEOUT which is included as an input parameter for bus.call dbus calls. The new alias makes the bus.call function shorter and readable.

Change-Id: I336c97bc0631d5370ff3648e41f50e3e283d771b
Signed-off-by: vkaverap@in.ibm.com <vkaverap@in.ibm.com>
diff --git a/common/utils.cpp b/common/utils.cpp
index 9162405..ae41265 100644
--- a/common/utils.cpp
+++ b/common/utils.cpp
@@ -426,9 +426,7 @@
         mapper.append(path, DbusInterfaceList({}));
     }
 
-    auto mapperResponseMsg = bus.call(
-        mapper,
-        std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+    auto mapperResponseMsg = bus.call(mapper, dbusTimeout);
     mapperResponseMsg.read(mapperResponse);
     return mapperResponse.begin()->first;
 }
@@ -441,9 +439,7 @@
     auto method = bus.new_method_call(mapperBusName, mapperPath,
                                       mapperInterface, "GetSubTree");
     method.append(searchPath, depth, ifaceList);
-    auto reply = bus.call(
-        method,
-        std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+    auto reply = bus.call(method, dbusTimeout);
     GetSubTreeResponse response;
     reply.read(response);
     return response;
@@ -557,9 +553,7 @@
                                       "Get");
     method.append(dbusInterface, dbusProp);
     PropertyValue value{};
-    auto reply = bus.call(
-        method,
-        std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+    auto reply = bus.call(method, dbusTimeout);
     reply.read(value);
     return value;
 }
diff --git a/common/utils.hpp b/common/utils.hpp
index 654b0b4..73e10eb 100644
--- a/common/utils.hpp
+++ b/common/utils.hpp
@@ -25,9 +25,6 @@
 #include <variant>
 #include <vector>
 
-using microsec = std::chrono::microseconds;
-using sec = std::chrono::seconds;
-
 constexpr uint64_t dbusTimeout =
     std::chrono::duration_cast<std::chrono::microseconds>(
         std::chrono::seconds(DBUS_TIMEOUT))
diff --git a/libpldmresponder/bios_config.cpp b/libpldmresponder/bios_config.cpp
index dec7b3f..e4b10c8 100644
--- a/libpldmresponder/bios_config.cpp
+++ b/libpldmresponder/bios_config.cpp
@@ -514,9 +514,7 @@
                                           "org.freedesktop.DBus.Properties",
                                           "Get");
         method.append(biosInterface, "BaseBIOSTable");
-        auto reply = bus.call(
-            method,
-            std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+        auto reply = bus.call(method, dbusTimeout);
         std::variant<BaseBIOSTable> varBiosTable{};
         reply.read(varBiosTable);
         biosTable = std::get<BaseBIOSTable>(varBiosTable);
diff --git a/libpldmresponder/fru.cpp b/libpldmresponder/fru.cpp
index 98f696c..0821cd2 100644
--- a/libpldmresponder/fru.cpp
+++ b/libpldmresponder/fru.cpp
@@ -157,9 +157,7 @@
         auto method = bus.new_method_call(
             std::get<0>(dbusInfo).c_str(), std::get<1>(dbusInfo).c_str(),
             "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
-        auto reply = bus.call(
-            method,
-            std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+        auto reply = bus.call(method, dbusTimeout);
         reply.read(objects);
     }
     catch (const std::exception& e)
@@ -253,9 +251,7 @@
                                           pldm::utils::dbusProperties, "Get");
         method.append("xyz.openbmc_project.Association", "endpoints");
         std::variant<std::vector<std::string>> paths;
-        auto reply = bus.call(
-            method,
-            std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+        auto reply = bus.call(method, dbusTimeout);
         reply.read(paths);
         auto fwRunningVersion = std::get<std::vector<std::string>>(paths)[0];
         constexpr auto versionIntf = "xyz.openbmc_project.Software.Version";
diff --git a/oem/ibm/libpldmresponder/file_io_type_dump.cpp b/oem/ibm/libpldmresponder/file_io_type_dump.cpp
index f23cb20..0792795 100644
--- a/oem/ibm/libpldmresponder/file_io_type_dump.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_dump.cpp
@@ -69,9 +69,7 @@
             bus.new_method_call(DUMP_MANAGER_BUSNAME, DUMP_MANAGER_PATH,
                                 OBJECT_MANAGER_INTERFACE, "GetManagedObjects");
 
-        auto reply = bus.call(
-            method,
-            std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+        auto reply = bus.call(method, dbusTimeout);
         reply.read(objects);
     }
     catch (const sdbusplus::exception_t& e)
@@ -287,9 +285,7 @@
                 auto method = bus.new_method_call(
                     "xyz.openbmc_project.Dump.Manager", path.c_str(),
                     "xyz.openbmc_project.Object.Delete", "Delete");
-                bus.call(method,
-                         std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT))
-                             .count());
+                bus.call(method, dbusTimeout);
             }
             catch (const std::exception& e)
             {
diff --git a/oem/ibm/libpldmresponder/file_io_type_pel.cpp b/oem/ibm/libpldmresponder/file_io_type_pel.cpp
index 2d1c68a..3e33cc6 100644
--- a/oem/ibm/libpldmresponder/file_io_type_pel.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_pel.cpp
@@ -108,9 +108,7 @@
         auto method = bus.new_method_call(service.c_str(), logObjPath,
                                           logInterface, "GetPEL");
         method.append(fileHandle);
-        auto reply = bus.call(
-            method,
-            std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+        auto reply = bus.call(method, dbusTimeout);
         sdbusplus::message::unix_fd fd{};
         reply.read(fd);
         auto rc = transferFileData(fd, true, offset, length, address);
@@ -141,9 +139,7 @@
         auto method = bus.new_method_call(service.c_str(), logObjPath,
                                           logInterface, "GetPEL");
         method.append(fileHandle);
-        auto reply = bus.call(
-            method,
-            std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+        auto reply = bus.call(method, dbusTimeout);
         sdbusplus::message::unix_fd fd{};
         reply.read(fd);
 
diff --git a/oem/ibm/libpldmresponder/file_io_type_vpd.cpp b/oem/ibm/libpldmresponder/file_io_type_vpd.cpp
index 9c14c33..e136214 100644
--- a/oem/ibm/libpldmresponder/file_io_type_vpd.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_vpd.cpp
@@ -38,7 +38,7 @@
                                           "org.freedesktop.DBus.Properties",
                                           "Get");
         method.append(keywrdInterface, keywrdPropName);
-        auto reply = bus.call(method);
+        auto reply = bus.call(method, dbusTimeout);
         reply.read(keywrd);
     }
     catch (const std::exception& e)
diff --git a/oem/ibm/libpldmresponder/inband_code_update.cpp b/oem/ibm/libpldmresponder/inband_code_update.cpp
index b74e101..e4fed04 100644
--- a/oem/ibm/libpldmresponder/inband_code_update.cpp
+++ b/oem/ibm/libpldmresponder/inband_code_update.cpp
@@ -170,9 +170,7 @@
         method.append("xyz.openbmc_project.Association", "endpoints");
         std::variant<std::vector<std::string>> paths;
 
-        auto reply = bus.call(
-            method,
-            std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+        auto reply = bus.call(method, dbusTimeout);
         reply.read(paths);
 
         runningVersion = std::get<std::vector<std::string>>(paths)[0];
@@ -181,9 +179,7 @@
                                            propIntf, "Get");
         method1.append("xyz.openbmc_project.Association", "endpoints");
 
-        auto reply1 = bus.call(
-            method1,
-            std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+        auto reply1 = bus.call(method1, dbusTimeout);
         reply1.read(paths);
         for (const auto& path : std::get<std::vector<std::string>>(paths))
         {
diff --git a/pldmtool/pldm_cmd_helper.cpp b/pldmtool/pldm_cmd_helper.cpp
index c8ce8df..54475e8 100644
--- a/pldmtool/pldm_cmd_helper.cpp
+++ b/pldmtool/pldm_cmd_helper.cpp
@@ -145,9 +145,7 @@
         auto method = bus.new_method_call(service.c_str(), pldmObjPath,
                                           pldmRequester, "GetInstanceId");
         method.append(mctp_eid);
-        auto reply = bus.call(
-            method,
-            std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+        auto reply = bus.call(method, dbusTimeout);
         reply.read(instanceId);
     }
     catch (const std::exception& e)
diff --git a/requester/mctp_endpoint_discovery.cpp b/requester/mctp_endpoint_discovery.cpp
index 5767314..bc50ee5 100644
--- a/requester/mctp_endpoint_discovery.cpp
+++ b/requester/mctp_endpoint_discovery.cpp
@@ -29,9 +29,7 @@
         auto method = bus.new_method_call(
             "xyz.openbmc_project.MCTP", "/xyz/openbmc_project/mctp",
             "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
-        auto reply = bus.call(
-            method,
-            std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+        auto reply = bus.call(method, dbusTimeout);
         reply.read(objects);
     }
     catch (const std::exception& e)
diff --git a/softoff/softoff.cpp b/softoff/softoff.cpp
index ec19988..be78933 100644
--- a/softoff/softoff.cpp
+++ b/softoff/softoff.cpp
@@ -143,9 +143,7 @@
         VMMMethod.append(TID, entityType,
                          (uint16_t)PLDM_STATE_SET_SW_TERMINATION_STATUS);
 
-        auto VMMResponseMsg = bus.call(
-            VMMMethod,
-            std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+        auto VMMResponseMsg = bus.call(VMMMethod, dbusTimeout);
 
         VMMResponseMsg.read(VMMResponse);
         if (VMMResponse.size() != 0)
@@ -187,9 +185,7 @@
         sysFwMethod.append(TID, entityType,
                            (uint16_t)PLDM_STATE_SET_SW_TERMINATION_STATUS);
 
-        auto sysFwResponseMsg = bus.call(
-            sysFwMethod,
-            std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+        auto sysFwResponseMsg = bus.call(sysFwMethod, dbusTimeout);
 
         sysFwResponseMsg.read(sysFwResponse);
 
@@ -238,9 +234,7 @@
         method.append(TID, entityType,
                       (uint16_t)PLDM_STATE_SET_SW_TERMINATION_STATUS);
 
-        auto ResponseMsg = bus.call(
-            method,
-            std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+        auto ResponseMsg = bus.call(method, dbusTimeout);
 
         ResponseMsg.read(Response);
 
@@ -310,9 +304,7 @@
             "xyz.openbmc_project.PLDM.Requester", "GetInstanceId");
         method.append(mctpEID);
 
-        auto ResponseMsg = bus.call(
-            method,
-            std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
+        auto ResponseMsg = bus.call(method, dbusTimeout);
 
         ResponseMsg.read(instanceID);
     }