phc2sys: default to the first clock in automatic mode.

If we have clocks to synchronize but no source, just pick the last one in
the list, which is the first one from the ptp4l command line.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2014-11-20 22:18:48 +01:00
parent e1ea4ea810
commit 2ab2fbbdda
1 changed files with 10 additions and 2 deletions

View File

@ -292,13 +292,12 @@ static void clock_reinit(struct clock *clock)
static void reconfigure(struct node *node)
{
struct clock *c, *rt, *src;
struct clock *c, *rt = NULL, *src = NULL, *last = NULL;
int src_cnt = 0, dst_cnt = 0;
pr_info("reconfiguring after port state change");
node->state_changed = 0;
src = rt = NULL;
LIST_FOREACH(c, &node->clocks, list) {
if (c->clkid == CLOCK_REALTIME) {
rt = c;
@ -331,6 +330,15 @@ static void reconfigure(struct node *node)
src_cnt++;
break;
}
last = c;
}
if (dst_cnt && !src) {
if (!rt || rt->dest_only) {
node->master = last;
pr_info("no source, selecting %s as the default clock",
last->device);
return;
}
}
if (src_cnt > 1) {
pr_info("multiple master clocks available, postponing sync...");