Skip to content

Commit

Permalink
ts2phc: Avoid unnecessary call of getppstime().
Browse files Browse the repository at this point in the history
Don't get the ToD timestamp for the pulse polarity detection if it won't
be needed (i.e. extts_polarity is not "both"). This allows PPS
timestamps to be saved even when the ToD source fails.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
  • Loading branch information
mlichvar authored and richardcochran committed Jul 22, 2024
1 parent 52beedf commit 9c48f5d
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions ts2phc_pps_sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,21 +275,22 @@ static enum extts_result ts2phc_pps_sink_event(struct ts2phc_private *priv,
goto out;
}

err = ts2phc_pps_source_getppstime(priv->src, &source_ts);
if (err < 0) {
pr_debug("source ts not valid");
return 0;
}

if (sink->polarity == (PTP_RISING_EDGE | PTP_FALLING_EDGE) &&
ts2phc_pps_sink_ignore(priv, sink, source_ts)) {
if (sink->polarity == (PTP_RISING_EDGE | PTP_FALLING_EDGE)) {
err = ts2phc_pps_source_getppstime(priv->src, &source_ts);
if (err < 0) {
pr_debug("source ts not valid");
return 0;
}

pr_debug("%s SKIP extts index %u at %lld.%09u src %" PRIi64 ".%ld",
sink->name, event.index, event.t.sec, event.t.nsec,
(int64_t) source_ts.tv_sec, source_ts.tv_nsec);
if (ts2phc_pps_sink_ignore(priv, sink, source_ts)) {
pr_debug("%s SKIP extts index %u at %lld.%09u src %" PRIi64 ".%ld",
sink->name, event.index, event.t.sec,
event.t.nsec, (int64_t)source_ts.tv_sec,
source_ts.tv_nsec);

result = EXTTS_IGNORE;
goto out;
result = EXTTS_IGNORE;
goto out;
}
}

out:
Expand Down

0 comments on commit 9c48f5d

Please sign in to comment.