Use the common NSEC_PER_SEC macro in port-related source code.

Signed-off-by: Rahul Rameshbabu <rrameshb...@nvidia.com>
---
 port.c         | 14 +++++++-------
 port_private.h |  3 +--
 tc.c           |  9 ++++-----
 3 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/port.c b/port.c
index 5803cd3..79f3702 100644
--- a/port.c
+++ b/port.c
@@ -138,17 +138,17 @@ static int msg_current(struct ptp_message *m, struct 
timespec now)
 {
        int64_t t1, t2, tmo;
 
-       t1 = m->ts.host.tv_sec * NSEC2SEC + m->ts.host.tv_nsec;
-       t2 = now.tv_sec * NSEC2SEC + now.tv_nsec;
+       t1 = m->ts.host.tv_sec * NSEC_PER_SEC + m->ts.host.tv_nsec;
+       t2 = now.tv_sec * NSEC_PER_SEC + now.tv_nsec;
 
        if (m->header.logMessageInterval <= -31) {
                tmo = 0;
        } else if (m->header.logMessageInterval >= 31) {
                tmo = INT64_MAX;
        } else if (m->header.logMessageInterval < 0) {
-               tmo = 4LL * NSEC2SEC / (1 << -m->header.logMessageInterval);
+               tmo = 4LL * NSEC_PER_SEC / (1 << -m->header.logMessageInterval);
        } else {
-               tmo = 4LL * (1 << m->header.logMessageInterval) * NSEC2SEC;
+               tmo = 4LL * (1 << m->header.logMessageInterval) * NSEC_PER_SEC;
        }
 
        return t2 - t1 < tmo;
@@ -340,10 +340,10 @@ static void fc_prune(struct foreign_clock *fc)
 
 static int delay_req_current(struct ptp_message *m, struct timespec now)
 {
-       int64_t t1, t2, tmo = 5 * NSEC2SEC;
+       int64_t t1, t2, tmo = 5 * NSEC_PER_SEC;
 
-       t1 = m->ts.host.tv_sec * NSEC2SEC + m->ts.host.tv_nsec;
-       t2 = now.tv_sec * NSEC2SEC + now.tv_nsec;
+       t1 = m->ts.host.tv_sec * NSEC_PER_SEC + m->ts.host.tv_nsec;
+       t2 = now.tv_sec * NSEC_PER_SEC + now.tv_nsec;
 
        return t2 - t1 < tmo;
 }
diff --git a/port_private.h b/port_private.h
index 3b02d2f..d922a3d 100644
--- a/port_private.h
+++ b/port_private.h
@@ -28,8 +28,7 @@
 #include "msg.h"
 #include "power_profile.h"
 #include "tmv.h"
-
-#define NSEC2SEC 1000000000LL
+#include "util.h"
 
 enum syfu_state {
        SF_EMPTY,
diff --git a/tc.c b/tc.c
index 1847041..20717c1 100644
--- a/tc.c
+++ b/tc.c
@@ -254,13 +254,12 @@ static void tc_complete(struct port *q, struct port *p,
 
 static int tc_current(struct ptp_message *m, struct timespec now)
 {
-       int64_t t1, t2, tmo;
+       int64_t t1, t2;
 
-       tmo = 1LL * NSEC2SEC;
-       t1 = m->ts.host.tv_sec * NSEC2SEC + m->ts.host.tv_nsec;
-       t2 = now.tv_sec * NSEC2SEC + now.tv_nsec;
+       t1 = m->ts.host.tv_sec * NSEC_PER_SEC + m->ts.host.tv_nsec;
+       t2 = now.tv_sec * NSEC_PER_SEC + now.tv_nsec;
 
-       return t2 - t1 < tmo;
+       return t2 - t1 < NSEC_PER_SEC;
 }
 
 static int tc_fwd_event(struct port *q, struct ptp_message *msg)
-- 
2.40.1



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to