From c9f3fad780b9d916de880baddef48b0a7132cc76 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 12 Mar 2018 12:36:27 +0000 Subject: [PATCH] clock: Remove open-coded conversion of struct timespec The function clock_check_ts() performs open-coded manipulation of a struct timespec instead of using the tmv_t abstractions. Use the existing tmv_t abstractions to convert from struct timespec to nanoseconds, and modify the prototype of clock_check_ts() to match that of the underlying clockcheck_sample(). Signed-off-by: Michael Brown --- clock.c | 6 ++---- clock.h | 2 +- port.c | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/clock.c b/clock.c index 199c0cb..cf087e8 100644 --- a/clock.c +++ b/clock.c @@ -1767,11 +1767,9 @@ enum clock_type clock_type(struct clock *c) return c->type; } -void clock_check_ts(struct clock *c, struct timespec ts) +void clock_check_ts(struct clock *c, uint64_t ts) { - if (c->sanity_check && - clockcheck_sample(c->sanity_check, - ts.tv_sec * NS_PER_SEC + ts.tv_nsec)) { + if (c->sanity_check && clockcheck_sample(c->sanity_check, ts)) { servo_reset(c->servo); } } diff --git a/clock.h b/clock.h index 94d4ad0..3fa026d 100644 --- a/clock.h +++ b/clock.h @@ -316,7 +316,7 @@ enum clock_type clock_type(struct clock *c); * @param c The clock instance. * @param ts The time stamp. */ -void clock_check_ts(struct clock *c, struct timespec ts); +void clock_check_ts(struct clock *c, uint64_t ts); /** * Obtain ratio between master's frequency and current clock frequency. diff --git a/port.c b/port.c index 25507e2..d1c95ab 100644 --- a/port.c +++ b/port.c @@ -2519,7 +2519,8 @@ enum fsm_event port_event(struct port *p, int fd_index) } if (msg_sots_valid(msg)) { ts_add(&msg->hwts.ts, -p->rx_timestamp_offset); - clock_check_ts(p->clock, msg->hwts.ts); + clock_check_ts(p->clock, + tmv_to_nanoseconds(timespec_to_tmv(msg->hwts.ts))); } if (port_ignore(p, msg)) { msg_put(msg);