Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1320230 > unrolled thread

[PATCH] ptp: ixp46x: use helpers for converting ns to timespec

Started byKefeng Wang <wangkefeng.wang@huawei.com>
First post2016-01-28 03:30 +0100
Last post2016-01-29 21:40 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] ptp: ixp46x: use helpers for converting ns to timespec Kefeng Wang <wangkefeng.wang@huawei.com> - 2016-01-28 03:30 +0100
    Re: [PATCH] ptp: ixp46x: use helpers for converting ns to timespec Richard Cochran <richardcochran@gmail.com> - 2016-01-28 10:50 +0100
    Re: [PATCH] ptp: ixp46x: use helpers for converting ns to timespec David Miller <davem@davemloft.net> - 2016-01-29 21:40 +0100

#1320230 — [PATCH] ptp: ixp46x: use helpers for converting ns to timespec

FromKefeng Wang <wangkefeng.wang@huawei.com>
Date2016-01-28 03:30 +0100
Subject[PATCH] ptp: ixp46x: use helpers for converting ns to timespec
Message-ID<qVKvo-4Ms-5@gated-at.bofh.it>
Convert the driver to use ns_to_timespec64() and timespec64_to_ns()
instead of open coding the same logic.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/ptp/ptp_ixp46x.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/ptp/ptp_ixp46x.c b/drivers/ptp/ptp_ixp46x.c
index 934c139..ee4f183 100644
--- a/drivers/ptp/ptp_ixp46x.c
+++ b/drivers/ptp/ptp_ixp46x.c
@@ -178,7 +178,6 @@ static int ptp_ixp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 static int ptp_ixp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 {
 	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;
@@ -189,8 +188,7 @@ static int ptp_ixp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 
 	spin_unlock_irqrestore(&register_lock, flags);
 
-	ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
-	ts->tv_nsec = remainder;
+	*ts = ns_to_timespec64(ns);
 	return 0;
 }
 
@@ -202,8 +200,7 @@ static int ptp_ixp_settime(struct ptp_clock_info *ptp,
 	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;
+	ns = timespec64_to_ns(ts);
 
 	spin_lock_irqsave(&register_lock, flags);
 
-- 
2.6.0.GIT

[toc] | [next] | [standalone]


#1320482

FromRichard Cochran <richardcochran@gmail.com>
Date2016-01-28 10:50 +0100
Message-ID<qVRnd-1sZ-29@gated-at.bofh.it>
In reply to#1320230
On Thu, Jan 28, 2016 at 10:27:19AM +0800, Kefeng Wang wrote:
> Convert the driver to use ns_to_timespec64() and timespec64_to_ns()
> instead of open coding the same logic.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  drivers/ptp/ptp_ixp46x.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)

Acked-by: Richard Cochran <richardcochran@gmail.com>

[toc] | [prev] | [next] | [standalone]


#1322060

FromDavid Miller <davem@davemloft.net>
Date2016-01-29 21:40 +0100
Message-ID<qWnZL-aN-3@gated-at.bofh.it>
In reply to#1320230
From: Kefeng Wang <wangkefeng.wang@huawei.com>
Date: Thu, 28 Jan 2016 10:27:19 +0800

> Convert the driver to use ns_to_timespec64() and timespec64_to_ns()
> instead of open coding the same logic.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

Applied, thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web