提交 b83ef507 编写于 作者: K Kefeng Wang 提交者: David S. Miller

ptp: ixp46x: use helpers for converting ns to timespec

Convert the driver to use ns_to_timespec64() and timespec64_to_ns()
instead of open coding the same logic.
Signed-off-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: NRichard Cochran <richardcochran@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 21603fc4
...@@ -178,7 +178,6 @@ static int ptp_ixp_adjtime(struct ptp_clock_info *ptp, s64 delta) ...@@ -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) static int ptp_ixp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
{ {
u64 ns; u64 ns;
u32 remainder;
unsigned long flags; unsigned long flags;
struct ixp_clock *ixp_clock = container_of(ptp, struct ixp_clock, caps); struct ixp_clock *ixp_clock = container_of(ptp, struct ixp_clock, caps);
struct ixp46x_ts_regs *regs = ixp_clock->regs; 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) ...@@ -189,8 +188,7 @@ static int ptp_ixp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
spin_unlock_irqrestore(&register_lock, flags); spin_unlock_irqrestore(&register_lock, flags);
ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder); *ts = ns_to_timespec64(ns);
ts->tv_nsec = remainder;
return 0; return 0;
} }
...@@ -202,8 +200,7 @@ static int ptp_ixp_settime(struct ptp_clock_info *ptp, ...@@ -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 ixp_clock *ixp_clock = container_of(ptp, struct ixp_clock, caps);
struct ixp46x_ts_regs *regs = ixp_clock->regs; struct ixp46x_ts_regs *regs = ixp_clock->regs;
ns = ts->tv_sec * 1000000000ULL; ns = timespec64_to_ns(ts);
ns += ts->tv_nsec;
spin_lock_irqsave(&register_lock, flags); spin_lock_irqsave(&register_lock, flags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册