Skip to content

Commit

Permalink
net: macb: Fix ptp time adjustment for large negative delta
Browse files Browse the repository at this point in the history
When delta passed to gem_ptp_adjtime is negative, the sign is
maintained in the ns_to_timespec64 conversion. Hence timespec_add
should be used directly. timespec_sub will just subtract the negative
value thus increasing the time difference.

Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Harini Katakam authored and David S. Miller committed Jun 21, 2018
1 parent 3087796 commit 64d7839
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions drivers/net/ethernet/cadence/macb_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,7 @@ static int gem_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)

if (delta > TSU_NSEC_MAX_VAL) {
gem_tsu_get_time(&bp->ptp_clock_info, &now);
if (sign)
now = timespec64_sub(now, then);
else
now = timespec64_add(now, then);
now = timespec64_add(now, then);

gem_tsu_set_time(&bp->ptp_clock_info,
(const struct timespec64 *)&now);
Expand Down

0 comments on commit 64d7839

Please sign in to comment.