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 <richardcoch...@gmail.com>
---
 phc2sys.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/phc2sys.c b/phc2sys.c
index 15ccb80..1b4f6ce 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -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,
@@ -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);
                }
-- 
2.20.1



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

Reply via email to