ptp: cpts: use helpers for converting ns to timespec.
authorRichard Cochran <richardcochran@gmail.com>
Tue, 31 Mar 2015 21:08:16 +0000 (23:08 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 31 Mar 2015 21:19:19 +0000 (17:19 -0400)
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 <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/cpts.c

index 074b6369da661f427a21b85d89f5efb9d296955d..85a55b4ff8c0731a1952068e968715b256afdb91 100644 (file)
@@ -170,7 +170,6 @@ static int cpts_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 static int cpts_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 {
        u64 ns;
-       u32 remainder;
        unsigned long flags;
        struct cpts *cpts = container_of(ptp, struct cpts, info);
 
@@ -178,8 +177,7 @@ static int cpts_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
        ns = timecounter_read(&cpts->tc);
        spin_unlock_irqrestore(&cpts->lock, flags);
 
-       ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
-       ts->tv_nsec = remainder;
+       *ts = ns_to_timespec64(ns);
 
        return 0;
 }
@@ -191,8 +189,7 @@ static int cpts_ptp_settime(struct ptp_clock_info *ptp,
        unsigned long flags;
        struct cpts *cpts = container_of(ptp, struct cpts, info);
 
-       ns = ts->tv_sec * 1000000000ULL;
-       ns += ts->tv_nsec;
+       ns = timespec64_to_ns(ts);
 
        spin_lock_irqsave(&cpts->lock, flags);
        timecounter_init(&cpts->tc, &cpts->cc, ns);