Skip to content

Commit

Permalink
phc2sys: Replace yet another magical test with a proper test.
Browse files Browse the repository at this point in the history
In the manual wait mode, if the system clock is not being used, the
program closes the PMC agent's connection once the ptp4l service has
appeared.  Presumably this is done because the TAI-UTC offset plays no
role in synchronizing two PHC devices.

In order to tell whether the system clock is being used, the code tests for

    src->clkid != CLOCK_REALTIME && dst->clkid != CLOCK_REALTIME

which is fairly non-obvious.  Clarify the intention of the code by
using a proper test.

Signed-off-by: Richard Cochran <[email protected]>
  • Loading branch information
richardcochran committed Dec 6, 2020
1 parent 5f1b419 commit 046fc05
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion phc2sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,18 @@ static bool hardpps_configured(int fd)
return fd >= 0;
}

static bool phc2sys_using_systemclock(struct phc2sys_private *priv)
{
struct clock *c;

LIST_FOREACH(c, &priv->clocks, list) {
if (c->clkid == CLOCK_REALTIME) {
return true;
}
}
return false;
}

static void usage(char *progname)
{
fprintf(stderr,
Expand Down Expand Up @@ -1327,7 +1339,7 @@ int main(int argc, char *argv[])
}

if (priv.forced_sync_offset ||
(src->clkid != CLOCK_REALTIME && dst->clkid != CLOCK_REALTIME) ||
!phc2sys_using_systemclock(&priv) ||
hardpps_configured(pps_fd)) {
pmc_agent_disable(priv.agent);
}
Expand Down

0 comments on commit 046fc05

Please sign in to comment.