diff mbox

[4/4] ptp/ixp46x:Replace timespec with ktime_t in ptp_ixp46x.c

Message ID 1426743909-24335-5-git-send-email-baolin.wang@linaro.org
State New
Headers show

Commit Message

(Exiting) Baolin Wang March 19, 2015, 5:45 a.m. UTC
This patch changes the 32-bit time type (timespec) to the 64-bit one
(ktime_t), since 32-bit time types will break in the year 2038.

This patch implements the getktime/setktime interfaces with
"ktime_t" type, and removes the gettime/settime interfaces with
"timespec" type in ptp_ixp46x.c file.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 drivers/ptp/ptp_ixp46x.c |   21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
diff mbox

Patch

diff --git a/drivers/ptp/ptp_ixp46x.c b/drivers/ptp/ptp_ixp46x.c
index 604d340..102b673 100644
--- a/drivers/ptp/ptp_ixp46x.c
+++ b/drivers/ptp/ptp_ixp46x.c
@@ -175,39 +175,30 @@  static int ptp_ixp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 	return 0;
 }
 
-static int ptp_ixp_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
+static int ptp_ixp_getktime(struct ptp_clock_info *ptp, ktime_t *kt)
 {
-	u64 ns;
-	u32 remainder;
 	unsigned long flags;
 	struct ixp_clock *ixp_clock = container_of(ptp, struct ixp_clock, caps);
 	struct ixp46x_ts_regs *regs = ixp_clock->regs;
 
 	spin_lock_irqsave(&register_lock, flags);
 
-	ns = ixp_systime_read(regs);
+	*kt = ns_to_ktime(ixp_systime_read(regs));
 
 	spin_unlock_irqrestore(&register_lock, flags);
 
-	ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
-	ts->tv_nsec = remainder;
 	return 0;
 }
 
-static int ptp_ixp_settime(struct ptp_clock_info *ptp,
-			   const struct timespec *ts)
+static int ptp_ixp_setktime(struct ptp_clock_info *ptp, ktime_t kt)
 {
-	u64 ns;
 	unsigned long flags;
 	struct ixp_clock *ixp_clock = container_of(ptp, struct ixp_clock, caps);
 	struct ixp46x_ts_regs *regs = ixp_clock->regs;
 
-	ns = ts->tv_sec * 1000000000ULL;
-	ns += ts->tv_nsec;
-
 	spin_lock_irqsave(&register_lock, flags);
 
-	ixp_systime_write(regs, ns);
+	ixp_systime_write(regs, ktime_to_ns(kt));
 
 	spin_unlock_irqrestore(&register_lock, flags);
 
@@ -248,8 +239,8 @@  static struct ptp_clock_info ptp_ixp_caps = {
 	.pps		= 0,
 	.adjfreq	= ptp_ixp_adjfreq,
 	.adjtime	= ptp_ixp_adjtime,
-	.gettime	= ptp_ixp_gettime,
-	.settime	= ptp_ixp_settime,
+	.getktime	= ptp_ixp_getktime,
+	.setktime	= ptp_ixp_setktime,
 	.enable		= ptp_ixp_enable,
 };