mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-21 14:11:20 +00:00
ptp_pch: use helpers function for converting between ns and timespec
use ns_to_timespec64() and timespec64_to_ns() instead of open coding Signed-off-by: YueHaibing <yuehaibing@huawei.com> Acked-by: Richard Cochran <richardcochran@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
28fb4e59a4
commit
80e95f472f
1 changed files with 2 additions and 5 deletions
|
@ -452,7 +452,6 @@ static int ptp_pch_adjtime(struct ptp_clock_info *ptp, s64 delta)
|
||||||
static int ptp_pch_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
|
static int ptp_pch_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
|
||||||
{
|
{
|
||||||
u64 ns;
|
u64 ns;
|
||||||
u32 remainder;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
|
struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
|
||||||
struct pch_ts_regs __iomem *regs = pch_dev->regs;
|
struct pch_ts_regs __iomem *regs = pch_dev->regs;
|
||||||
|
@ -461,8 +460,7 @@ static int ptp_pch_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
|
||||||
ns = pch_systime_read(regs);
|
ns = pch_systime_read(regs);
|
||||||
spin_unlock_irqrestore(&pch_dev->register_lock, flags);
|
spin_unlock_irqrestore(&pch_dev->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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,8 +472,7 @@ static int ptp_pch_settime(struct ptp_clock_info *ptp,
|
||||||
struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
|
struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
|
||||||
struct pch_ts_regs __iomem *regs = pch_dev->regs;
|
struct pch_ts_regs __iomem *regs = pch_dev->regs;
|
||||||
|
|
||||||
ns = ts->tv_sec * 1000000000ULL;
|
ns = timespec64_to_ns(ts);
|
||||||
ns += ts->tv_nsec;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&pch_dev->register_lock, flags);
|
spin_lock_irqsave(&pch_dev->register_lock, flags);
|
||||||
pch_systime_write(regs, ns);
|
pch_systime_write(regs, ns);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue