When using a PPS time source, the code only checks the destination
clock after performing much static setup.  There is no need to delay
the validation, so move this to the other sanity checks.

Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
---
 phc2sys.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index f28e9be..03347f0 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1245,6 +1245,15 @@ int main(int argc, char *argv[])
                goto bad_usage;
        }
 
+       if (!dst_name) {
+               dst_name = "CLOCK_REALTIME";
+       }
+       if (hardpps_configured(pps_fd) && strcmp(dst_name, "CLOCK_REALTIME")) {
+               fprintf(stderr,
+                       "cannot use a pps device unless destination is 
CLOCK_REALTIME\n");
+               goto bad_usage;
+       }
+
        print_set_progname(progname);
        print_set_tag(config_get_string(cfg, NULL, "message_tag"));
        print_set_verbose(config_get_int(cfg, NULL, "verbose"));
@@ -1280,7 +1289,7 @@ int main(int argc, char *argv[])
        src->state = PS_SLAVE;
        priv.master = src;
 
-       dst = clock_add(&priv, dst_name ? dst_name : "CLOCK_REALTIME");
+       dst = clock_add(&priv, dst_name);
        if (!dst) {
                fprintf(stderr, "valid destination clock must be selected.\n");
                goto bad_usage;
@@ -1288,12 +1297,6 @@ int main(int argc, char *argv[])
        dst->state = PS_MASTER;
        LIST_INSERT_HEAD(&priv.dst_clocks, dst, dst_list);
 
-       if (hardpps_configured(pps_fd) && dst->clkid != CLOCK_REALTIME) {
-               fprintf(stderr,
-                       "cannot use a pps device unless destination is 
CLOCK_REALTIME\n");
-               goto bad_usage;
-       }
-
        r = -1;
 
        if (wait_sync) {
-- 
2.20.1



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to