Skip to content

Commit 6630514

Browse files
richardcochrandavem330
authored andcommitted
ptp: fec: use helpers for converting ns to timespec.
This patch changes the driver to use ns_to_timespec64() and timespec64_to_ns() instead of open coding the same logic. Compile tested only. Signed-off-by: Richard Cochran <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7a20efb commit 6630514

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/net/ethernet/freescale/fec_ptp.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,13 @@ static int fec_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
395395
struct fec_enet_private *adapter =
396396
container_of(ptp, struct fec_enet_private, ptp_caps);
397397
u64 ns;
398-
u32 remainder;
399398
unsigned long flags;
400399

401400
spin_lock_irqsave(&adapter->tmreg_lock, flags);
402401
ns = timecounter_read(&adapter->tc);
403402
spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
404403

405-
ts->tv_sec = div_u64_rem(ns, 1000000000ULL, &remainder);
406-
ts->tv_nsec = remainder;
404+
*ts = ns_to_timespec64(ns);
407405

408406
return 0;
409407
}
@@ -433,8 +431,7 @@ static int fec_ptp_settime(struct ptp_clock_info *ptp,
433431
return -EINVAL;
434432
}
435433

436-
ns = ts->tv_sec * 1000000000ULL;
437-
ns += ts->tv_nsec;
434+
ns = timespec64_to_ns(ts);
438435
/* Get the timer value based on timestamp.
439436
* Update the counter with the masked value.
440437
*/

0 commit comments

Comments
 (0)