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 <mbrown@fensystems.co.uk>
master
Michael Brown 2018-03-12 12:36:27 +00:00 committed by Richard Cochran
parent ab8dc20cf7
commit c9f3fad780
3 changed files with 5 additions and 6 deletions

View File

@ -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);
}
}

View File

@ -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.

3
port.c
View File

@ -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);