Date: Thu, 7 Jul 2022 17:25:05 +0200 From: Sebastian Huber <sebastian.huber@embedded-brains.de> To: freebsd-hackers@freebsd.org Subject: [PATCH 5/6] pps: Simplify the nsec calculation in pps_event() Message-ID: <20220707152506.55626-6-sebastian.huber@embedded-brains.de> In-Reply-To: <20220707152506.55626-1-sebastian.huber@embedded-brains.de> References: <20220707152506.55626-1-sebastian.huber@embedded-brains.de>
next in thread | previous in thread | raw e-mail | index | archive | help
---
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20220707152506.55626-6-sebastian.huber>
