[PATCH 5/6] pps: Simplify the nsec calculation in pps_event()
- In reply to: Sebastian Huber : "[PATCH 0/6] Simplify pps_capture() and pps_event()"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 07 Jul 2022 15:25:05 UTC
---
sys/kern/kern_tc.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index be564e4347f8..f29dd9b8e7f2 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -1781,7 +1781,7 @@ pps_event(struct pps_state *pps, int event)
struct timecounter *captc;
uint64_t capth_scale;
struct bintime bt;
- struct timespec ts, *tsp, *osp;
+ struct timespec *tsp, *osp;
u_int tcount, *pcount;
int foff;
pps_seq_t *pseq;
@@ -1881,7 +1881,7 @@ pps_event(struct pps_state *pps, int event)
#ifdef PPS_SYNC
if (fhard) {
- uint64_t scale;
+ uint64_t nsec;
/*
* Feed the NTP PLL/FLL.
@@ -1891,14 +1891,10 @@ pps_event(struct pps_state *pps, int event)
tcount = pps->capcount - pps->ppscount[2];
pps->ppscount[2] = pps->capcount;
tcount &= captc->tc_counter_mask;
- scale = (uint64_t)1 << 63;
- scale /= captc->tc_frequency;
- scale *= 2;
- bt.sec = 0;
- bt.frac = 0;
- bintime_addx(&bt, scale * tcount);
- bintime2timespec(&bt, &ts);
- hardpps(tsp, ts.tv_nsec + 1000000000 * ts.tv_sec);
+ nsec = 1000000000;
+ nsec *= tcount;
+ nsec /= captc->tc_frequency;
+ hardpps(tsp, (long)nsec);
}
#endif
--
2.35.3