Skip to content

Commit b3505fb

Browse files
tomasixyskartben
authored andcommitted
net: lib: ptp: Fix bidir time adjustment
When the offset is larger than 1 second, the time adjustment should still be allowed to be bidirectional. Casting the offset to an unsigned value after the subtraction will allow the adjustment to be bidirectional. Signed-off-by: Tomas Choat <[email protected]>
1 parent ecfc444 commit b3505fb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

subsys/net/lib/ptp/clock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,8 @@ void ptp_clock_synchronize(uint64_t ingress, uint64_t egress)
529529

530530
ptp_clock_get(ptp_clk.phc, &current);
531531

532-
current.second -= (uint64_t)(offset / NSEC_PER_SEC);
533-
dest_nsec = (int32_t)(current.nanosecond - (uint32_t)(offset % NSEC_PER_SEC));
532+
current.second = (uint64_t)(current.second - (offset / NSEC_PER_SEC));
533+
dest_nsec = (int32_t)(current.nanosecond - (offset % NSEC_PER_SEC));
534534

535535
if (dest_nsec < 0) {
536536
current.second--;

0 commit comments

Comments
 (0)