From 220a60a425146b0e37998cc0b3082f0541aad866 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 3 Sep 2012 11:34:58 +0100 Subject: pps/ptp: Allow PHC devices to adjust PPS events for known delay Initial version by Stuart Hodgson Some PHC device drivers may deliver PPS events with a significant and variable delay, but still be able to measure precisely what that delay is. Add a pps_sub_ts() function for subtracting a delay from the timestamp(s) in a PPS event, and a PTP event type (PTP_CLOCK_PPSUSR) for which the caller provides a complete PPS event. Signed-off-by: Ben Hutchings --- include/linux/pps_kernel.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/linux/pps_kernel.h') diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h index 94048547f29a..0cc45ae1afd5 100644 --- a/include/linux/pps_kernel.h +++ b/include/linux/pps_kernel.h @@ -116,5 +116,14 @@ static inline void pps_get_ts(struct pps_event_time *ts) #endif /* CONFIG_NTP_PPS */ +/* Subtract known time delay from PPS event time(s) */ +static inline void pps_sub_ts(struct pps_event_time *ts, struct timespec delta) +{ + ts->ts_real = timespec_sub(ts->ts_real, delta); +#ifdef CONFIG_NTP_PPS + ts->ts_raw = timespec_sub(ts->ts_raw, delta); +#endif +} + #endif /* LINUX_PPS_KERNEL_H */ -- cgit