Currently, if the -c parameter is used multiple times only the last clock will be synchronized and no error will be returned.
This patch implements proper support for multiple -c parameter and will synchronize all clocks to the selected source. Signed-off-by: Maciek Machnikowski <mac...@machnikowski.net> --- phc2sys.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/phc2sys.c b/phc2sys.c index 599f9bd..66c16d0 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -967,11 +967,10 @@ static bool hardpps_configured(int fd) return fd >= 0; } -static int phc2sys_static_configuration(struct phc2sys_private *priv, - const char *src_name, - const char *dst_name) +static int phc2sys_static_src_configuration(struct phc2sys_private *priv, + const char *src_name) { - struct clock *src, *dst; + struct clock *src; src = clock_add(priv, src_name, -1); if (!src) { @@ -981,6 +980,14 @@ static int phc2sys_static_configuration(struct phc2sys_private *priv, src->state = PS_SLAVE; priv->master = src; + return 0; +} + +static int phc2sys_static_dst_configuration(struct phc2sys_private *priv, + const char *dst_name) +{ + struct clock *dst; + dst = clock_add(priv, dst_name, -1); if (!dst) { fprintf(stderr, "valid destination clock must be selected.\n"); @@ -1096,6 +1103,10 @@ int main(int argc, char *argv[]) break; case 'c': dst_name = optarg; + r = phc2sys_static_dst_configuration(&priv, dst_name); + if (r) { + goto end; + } break; case 'd': pps_fd = open(optarg, O_RDONLY); @@ -1266,6 +1277,10 @@ int main(int argc, char *argv[]) if (!dst_name) { dst_name = "CLOCK_REALTIME"; + r = phc2sys_static_dst_configuration(&priv, dst_name); + if (r) { + goto end; + } } if (hardpps_configured(pps_fd) && strcmp(dst_name, "CLOCK_REALTIME")) { fprintf(stderr, @@ -1300,7 +1315,7 @@ int main(int argc, char *argv[]) goto end; } - r = phc2sys_static_configuration(&priv, src_name, dst_name); + r = phc2sys_static_src_configuration(&priv, src_name); if (r) { goto end; } -- 2.36.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel