@@ -509,7 +509,7 @@ int ptp_clock_management_msg_process(struct ptp_port *port, struct ptp_msg *msg)
509509void ptp_clock_synchronize (uint64_t ingress , uint64_t egress )
510510{
511511 int64_t offset ;
512- uint64_t delay = ptp_clk .current_ds .mean_delay >> 16 ;
512+ int64_t delay = ptp_clk .current_ds .mean_delay >> 16 ;
513513
514514 ptp_clk .timestamp .t1 = egress ;
515515 ptp_clk .timestamp .t2 = ingress ;
@@ -518,7 +518,7 @@ void ptp_clock_synchronize(uint64_t ingress, uint64_t egress)
518518 return ;
519519 }
520520
521- offset = ptp_clk .timestamp .t2 - ptp_clk .timestamp .t1 - delay ;
521+ offset = ( int64_t )( ptp_clk .timestamp .t2 - ptp_clk .timestamp .t1 ) - delay ;
522522
523523 /* If diff is too big, ptp_clk needs to be set first. */
524524 if ((offset > (int64_t )NSEC_PER_SEC ) || (offset < - (int64_t )NSEC_PER_SEC )) {
@@ -559,8 +559,9 @@ void ptp_clock_delay(uint64_t egress, uint64_t ingress)
559559 ptp_clk .timestamp .t3 = egress ;
560560 ptp_clk .timestamp .t4 = ingress ;
561561
562- delay = ((ptp_clk .timestamp .t2 - ptp_clk .timestamp .t3 ) +
563- (ptp_clk .timestamp .t4 - ptp_clk .timestamp .t1 )) / 2 ;
562+ delay = ((int64_t )(ptp_clk .timestamp .t2 - ptp_clk .timestamp .t3 ) +
563+ (int64_t )(ptp_clk .timestamp .t4 - ptp_clk .timestamp .t1 )) /
564+ 2LL ;
564565
565566 LOG_DBG ("Delay %lldns" , delay );
566567 ptp_clk .current_ds .mean_delay = clock_ns_to_timeinterval (delay );
0 commit comments