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
parent
e1ea4ea810
commit
2ab2fbbdda
12
phc2sys.c
12
phc2sys.c
|
@ -292,13 +292,12 @@ static void clock_reinit(struct clock *clock)
|
||||||
|
|
||||||
static void reconfigure(struct node *node)
|
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;
|
int src_cnt = 0, dst_cnt = 0;
|
||||||
|
|
||||||
pr_info("reconfiguring after port state change");
|
pr_info("reconfiguring after port state change");
|
||||||
node->state_changed = 0;
|
node->state_changed = 0;
|
||||||
|
|
||||||
src = rt = NULL;
|
|
||||||
LIST_FOREACH(c, &node->clocks, list) {
|
LIST_FOREACH(c, &node->clocks, list) {
|
||||||
if (c->clkid == CLOCK_REALTIME) {
|
if (c->clkid == CLOCK_REALTIME) {
|
||||||
rt = c;
|
rt = c;
|
||||||
|
@ -331,6 +330,15 @@ static void reconfigure(struct node *node)
|
||||||
src_cnt++;
|
src_cnt++;
|
||||||
break;
|
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) {
|
if (src_cnt > 1) {
|
||||||
pr_info("multiple master clocks available, postponing sync...");
|
pr_info("multiple master clocks available, postponing sync...");
|
||||||
|
|
Loading…
Reference in New Issue