From: Alexander Gordeev on 24 Feb 2010 07:30 Add a helper function to gather timestamps. This way clients don't have to duplicate it. Signed-off-by: Alexander Gordeev <lasaine(a)lvk.cs.msu.su> --- drivers/pps/kapi.c | 15 +++++++++------ include/linux/pps_kernel.h | 23 ++++++++++++++++++++++- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/drivers/pps/kapi.c b/drivers/pps/kapi.c index 2d414e2..b87f699 100644 --- a/drivers/pps/kapi.c +++ b/drivers/pps/kapi.c @@ -267,7 +267,7 @@ EXPORT_SYMBOL(pps_unregister_source); * pps->info.echo(source, event, data); */ -void pps_event(int source, struct pps_ktime *ts, int event, void *data) +void pps_event(int source, struct pps_event_time *ts, int event, void *data) { struct pps_device *pps; unsigned long flags; @@ -284,7 +284,8 @@ void pps_event(int source, struct pps_ktime *ts, int event, void *data) return; pr_debug("PPS event on source %d at %llu.%06u\n", - pps->id, (unsigned long long) ts->sec, ts->nsec); + pps->id, (unsigned long long) ts->ts_real.sec, + ts->ts_real.nsec); spin_lock_irqsave(&pps->lock, flags); @@ -298,10 +299,11 @@ void pps_event(int source, struct pps_ktime *ts, int event, void *data) (pps->params.mode & PPS_CAPTUREASSERT)) { /* We have to add an offset? */ if (pps->params.mode & PPS_OFFSETASSERT) - pps_add_offset(ts, &pps->params.assert_off_tu); + pps_add_offset(&ts->ts_real, + &pps->params.assert_off_tu); /* Save the time stamp */ - pps->assert_tu = *ts; + pps->assert_tu = ts->ts_real; pps->assert_sequence++; pr_debug("capture assert seq #%u for source %d\n", pps->assert_sequence, source); @@ -312,10 +314,11 @@ void pps_event(int source, struct pps_ktime *ts, int event, void *data) (pps->params.mode & PPS_CAPTURECLEAR)) { /* We have to add an offset? */ if (pps->params.mode & PPS_OFFSETCLEAR) - pps_add_offset(ts, &pps->params.clear_off_tu); + pps_add_offset(&ts->ts_real, + &pps->params.clear_off_tu); /* Save the time stamp */ - pps->clear_tu = *ts; + pps->clear_tu = ts->ts_real; pps->clear_sequence++; pr_debug("capture clear seq #%u for source %d\n", pps->clear_sequence, source); diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h index e0a193f..a2804c1 100644 --- a/include/linux/pps_kernel.h +++ b/include/linux/pps_kernel.h @@ -40,6 +40,10 @@ struct pps_source_info { struct device *dev; }; +struct pps_event_time { + struct pps_ktime ts_real; +}; + /* The main struct */ struct pps_device { struct pps_source_info info; /* PSS source info */ @@ -86,4 +90,21 @@ extern int pps_register_source(struct pps_source_info *info, extern void pps_unregister_source(int source); extern int pps_register_cdev(struct pps_device *pps); extern void pps_unregister_cdev(struct pps_device *pps); -extern void pps_event(int source, struct pps_ktime *ts, int event, void *data); +extern void pps_event(int source, struct pps_event_time *ts, int event, + void *data); + +static inline void timespec_to_pps_ktime(struct pps_ktime *kt, + struct timespec ts) +{ + kt->sec = ts.tv_sec; + kt->nsec = ts.tv_nsec; +} + +static inline void pps_get_ts(struct pps_event_time *ts) +{ + struct timespec ts_real; + + getnstimeofday(&ts_real); + timespec_to_pps_ktime(&ts->ts_real, ts_real); +} + -- 1.6.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|
Pages: 1 Prev: tuntap with tun_no_pi and X25 question Next: [PATCHv2 6/6] pps: add parallel port PPS client |