aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pps
diff options
context:
space:
mode:
authorAlexander Gordeev <lasaine@lvk.cs.msu.su>2011-01-12 20:00:50 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-13 11:03:19 -0500
commit6f4229b51106cbc859e9d8209b22c8a2ec749e64 (patch)
tree346e08800b0f45330e99c9fae0255c73f1666835 /drivers/pps
parent3003d55b59aa98aeaff2773df69732b27c0cbf6a (diff)
pps: unify timestamp gathering
Add a helper function to gather timestamps. This way clients don't have to duplicate it. Signed-off-by: Alexander Gordeev <lasaine@lvk.cs.msu.su> Acked-by: Rodolfo Giometti <giometti@linux.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pps')
-rw-r--r--drivers/pps/clients/pps-ktimer.c9
-rw-r--r--drivers/pps/clients/pps-ldisc.c18
-rw-r--r--drivers/pps/kapi.c19
3 files changed, 20 insertions, 26 deletions
diff --git a/drivers/pps/clients/pps-ktimer.c b/drivers/pps/clients/pps-ktimer.c
index e7ef5b8186d0..e1bdd8bc8c9c 100644
--- a/drivers/pps/clients/pps-ktimer.c
+++ b/drivers/pps/clients/pps-ktimer.c
@@ -40,18 +40,13 @@ static struct timer_list ktimer;
40 40
41static void pps_ktimer_event(unsigned long ptr) 41static void pps_ktimer_event(unsigned long ptr)
42{ 42{
43 struct timespec __ts; 43 struct pps_event_time ts;
44 struct pps_ktime ts;
45 44
46 /* First of all we get the time stamp... */ 45 /* First of all we get the time stamp... */
47 getnstimeofday(&__ts); 46 pps_get_ts(&ts);
48 47
49 pr_info("PPS event at %lu\n", jiffies); 48 pr_info("PPS event at %lu\n", jiffies);
50 49
51 /* ... and translate it to PPS time data struct */
52 ts.sec = __ts.tv_sec;
53 ts.nsec = __ts.tv_nsec;
54
55 pps_event(source, &ts, PPS_CAPTUREASSERT, NULL); 50 pps_event(source, &ts, PPS_CAPTUREASSERT, NULL);
56 51
57 mod_timer(&ktimer, jiffies + HZ); 52 mod_timer(&ktimer, jiffies + HZ);
diff --git a/drivers/pps/clients/pps-ldisc.c b/drivers/pps/clients/pps-ldisc.c
index 8e1932d29fd4..20fc9f7645c8 100644
--- a/drivers/pps/clients/pps-ldisc.c
+++ b/drivers/pps/clients/pps-ldisc.c
@@ -27,26 +27,20 @@
27#define PPS_TTY_MAGIC 0x0001 27#define PPS_TTY_MAGIC 0x0001
28 28
29static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status, 29static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status,
30 struct timespec *ts) 30 struct pps_event_time *ts)
31{ 31{
32 int id = (long)tty->disc_data; 32 int id = (long)tty->disc_data;
33 struct timespec __ts; 33 struct pps_event_time __ts;
34 struct pps_ktime pps_ts;
35 34
36 /* First of all we get the time stamp... */ 35 /* First of all we get the time stamp... */
37 getnstimeofday(&__ts); 36 pps_get_ts(&__ts);
38 37
39 /* Does caller give us a timestamp? */ 38 /* Does caller give us a timestamp? */
40 if (ts) { /* Yes. Let's use it! */ 39 if (!ts) /* No. Do it ourself! */
41 pps_ts.sec = ts->tv_sec; 40 ts = &__ts;
42 pps_ts.nsec = ts->tv_nsec;
43 } else { /* No. Do it ourself! */
44 pps_ts.sec = __ts.tv_sec;
45 pps_ts.nsec = __ts.tv_nsec;
46 }
47 41
48 /* Now do the PPS event report */ 42 /* Now do the PPS event report */
49 pps_event(id, &pps_ts, status ? PPS_CAPTUREASSERT : PPS_CAPTURECLEAR, 43 pps_event(id, ts, status ? PPS_CAPTUREASSERT : PPS_CAPTURECLEAR,
50 NULL); 44 NULL);
51 45
52 pr_debug("PPS %s at %lu on source #%d\n", 46 pr_debug("PPS %s at %lu on source #%d\n",
diff --git a/drivers/pps/kapi.c b/drivers/pps/kapi.c
index 3f89f5eba81c..b431d83b824a 100644
--- a/drivers/pps/kapi.c
+++ b/drivers/pps/kapi.c
@@ -268,11 +268,12 @@ EXPORT_SYMBOL(pps_unregister_source);
268 * pps->info.echo(source, event, data); 268 * pps->info.echo(source, event, data);
269 */ 269 */
270 270
271void pps_event(int source, struct pps_ktime *ts, int event, void *data) 271void pps_event(int source, struct pps_event_time *ts, int event, void *data)
272{ 272{
273 struct pps_device *pps; 273 struct pps_device *pps;
274 unsigned long flags; 274 unsigned long flags;
275 int captured = 0; 275 int captured = 0;
276 struct pps_ktime ts_real;
276 277
277 if ((event & (PPS_CAPTUREASSERT | PPS_CAPTURECLEAR)) == 0) { 278 if ((event & (PPS_CAPTUREASSERT | PPS_CAPTURECLEAR)) == 0) {
278 printk(KERN_ERR "pps: unknown event (%x) for source %d\n", 279 printk(KERN_ERR "pps: unknown event (%x) for source %d\n",
@@ -284,8 +285,10 @@ void pps_event(int source, struct pps_ktime *ts, int event, void *data)
284 if (!pps) 285 if (!pps)
285 return; 286 return;
286 287
287 pr_debug("PPS event on source %d at %llu.%06u\n", 288 pr_debug("PPS event on source %d at %ld.%09ld\n",
288 pps->id, (unsigned long long) ts->sec, ts->nsec); 289 pps->id, ts->ts_real.tv_sec, ts->ts_real.tv_nsec);
290
291 timespec_to_pps_ktime(&ts_real, ts->ts_real);
289 292
290 spin_lock_irqsave(&pps->lock, flags); 293 spin_lock_irqsave(&pps->lock, flags);
291 294
@@ -299,10 +302,11 @@ void pps_event(int source, struct pps_ktime *ts, int event, void *data)
299 (pps->params.mode & PPS_CAPTUREASSERT)) { 302 (pps->params.mode & PPS_CAPTUREASSERT)) {
300 /* We have to add an offset? */ 303 /* We have to add an offset? */
301 if (pps->params.mode & PPS_OFFSETASSERT) 304 if (pps->params.mode & PPS_OFFSETASSERT)
302 pps_add_offset(ts, &pps->params.assert_off_tu); 305 pps_add_offset(&ts_real,
306 &pps->params.assert_off_tu);
303 307
304 /* Save the time stamp */ 308 /* Save the time stamp */
305 pps->assert_tu = *ts; 309 pps->assert_tu = ts_real;
306 pps->assert_sequence++; 310 pps->assert_sequence++;
307 pr_debug("capture assert seq #%u for source %d\n", 311 pr_debug("capture assert seq #%u for source %d\n",
308 pps->assert_sequence, source); 312 pps->assert_sequence, source);
@@ -313,10 +317,11 @@ void pps_event(int source, struct pps_ktime *ts, int event, void *data)
313 (pps->params.mode & PPS_CAPTURECLEAR)) { 317 (pps->params.mode & PPS_CAPTURECLEAR)) {
314 /* We have to add an offset? */ 318 /* We have to add an offset? */
315 if (pps->params.mode & PPS_OFFSETCLEAR) 319 if (pps->params.mode & PPS_OFFSETCLEAR)
316 pps_add_offset(ts, &pps->params.clear_off_tu); 320 pps_add_offset(&ts_real,
321 &pps->params.clear_off_tu);
317 322
318 /* Save the time stamp */ 323 /* Save the time stamp */
319 pps->clear_tu = *ts; 324 pps->clear_tu = ts_real;
320 pps->clear_sequence++; 325 pps->clear_sequence++;
321 pr_debug("capture clear seq #%u for source %d\n", 326 pr_debug("capture clear seq #%u for source %d\n",
322 pps->clear_sequence, source); 327 pps->clear_sequence, source);