If the user has configured the appropriate option, then simply warn about
the clock device mismatch, open the port's clock device, and then go on.

Signed-off-by: Richard Cochran <[email protected]>
---
 port.c |   25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/port.c b/port.c
index 2176962..95b6794 100644
--- a/port.c
+++ b/port.c
@@ -29,6 +29,7 @@
 #include "filter.h"
 #include "missing.h"
 #include "msg.h"
+#include "phc.h"
 #include "port.h"
 #include "print.h"
 #include "sk.h"
@@ -65,6 +66,7 @@ struct port {
        char *name;
        struct clock *clock;
        clockid_t clkid;
+       int max_adj;
        struct transport *trp;
        enum timestamp_type timestamping;
        struct fdarray fda;
@@ -1952,6 +1954,8 @@ void port_close(struct port *p)
        filter_destroy(p->delay_filter);
        if (p->fault_fd >= 0)
                close(p->fault_fd);
+       if (p->max_adj)
+               phc_close(p->clkid);
        free(p);
 }
 
@@ -2463,10 +2467,25 @@ struct port *port_open(clockid_t clkid,
        else if (!interface->ts_info.valid)
                pr_warning("port %d: get_ts_info not supported", number);
        else if (phc_index >= 0 && phc_index != interface->ts_info.phc_index) {
+               char phc[32];
+               snprintf(phc, 31, "/dev/ptp%d", interface->ts_info.phc_index);
                pr_err("port %d: PHC device mismatch", number);
-               pr_err("port %d: /dev/ptp%d requested, but /dev/ptp%d attached",
-                      number, phc_index, interface->ts_info.phc_index);
-               goto err_port;
+               pr_err("port %d: /dev/ptp%d requested, but %s attached",
+                      number, phc_index, phc);
+               if (!interface->boundary_clock_jbod) {
+                       goto err_port;
+               }
+               pr_warning("port %d: just a bunch of devices", number);
+               p->clkid = phc_open(phc);
+               if (p->clkid == CLOCK_INVALID) {
+                       pr_err("port %d: Failed to open %s: %m", number, phc);
+                       goto err_port;
+               }
+               p->max_adj = phc_max_adj(p->clkid);
+               if (!p->max_adj) {
+                       pr_err("port %d: clock is not adjustable", number);
+                       goto err_port;
+               }
        }
 
        p->pod = interface->pod;
-- 
1.7.10.4


------------------------------------------------------------------------------
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to