From 3414d99609f7119c2dc32768e0005ea28ae0f306 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Tue, 7 May 2013 14:32:21 +0200 Subject: [PATCH] phc2sys: Use currentUtcOffset only with PTP timescale. Signed-off-by: Miroslav Lichvar --- phc2sys.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/phc2sys.c b/phc2sys.c index 7649c8a..9db0529 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -368,6 +368,7 @@ static int run_pmc(struct clock *clock, int timeout, int wait_sync, int get_utc_offset) { struct ptp_message *msg; + struct timePropertiesDS *tds; void *data; #define N_FD 1 struct pollfd pollfd[N_FD]; @@ -440,14 +441,16 @@ static int run_pmc(struct clock *clock, int timeout, break; case TIME_PROPERTIES_DATA_SET: - clock->sync_offset = ((struct timePropertiesDS *)data)-> - currentUtcOffset; - if (((struct timePropertiesDS *)data)->flags & LEAP_61) - clock->leap = 1; - else if (((struct timePropertiesDS *)data)->flags & LEAP_59) - clock->leap = -1; - else - clock->leap = 0; + tds = (struct timePropertiesDS *)data; + if (tds->flags & PTP_TIMESCALE) { + clock->sync_offset = tds->currentUtcOffset; + if (tds->flags & LEAP_61) + clock->leap = 1; + else if (tds->flags & LEAP_59) + clock->leap = -1; + else + clock->leap = 0; + } ds_done = 1; break; }