The current version of the code resets status flags, with the exception of the leap second flag.
The fix is to read previously set flags and add STA_INS/STA_DEL on top of them. Signed-off-by: Alex Sergeev <aserg...@carbonrobotics.com> --- clockadj.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/clockadj.c b/clockadj.c index b5c78cd..21aef1d 100644 --- a/clockadj.c +++ b/clockadj.c @@ -144,19 +144,25 @@ void sysclk_set_leap(int leap) clockid_t clkid = CLOCK_REALTIME; struct timex tx; const char *m = NULL; + int prev_status; + + memset(&tx, 0, sizeof(tx)); + if (clock_adjtime(clkid, &tx) < 0) + pr_err("failed to get the clock status: %m"); + prev_status = tx.status; + memset(&tx, 0, sizeof(tx)); tx.modes = ADJ_STATUS; + tx.status = prev_status & ~(STA_INS | STA_DEL); switch (leap) { case -1: - tx.status = STA_DEL; + tx.status |= STA_DEL; m = "clock set to delete leap second at midnight (UTC)"; break; case 1: - tx.status = STA_INS; + tx.status |= STA_INS; m = "clock set to insert leap second at midnight (UTC)"; break; - default: - tx.status = 0; } if (clock_adjtime(clkid, &tx) < 0) pr_err("failed to set the clock status: %m"); -- 2.24.0 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel