aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pps/clients/pps-ktimer.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pps/clients/pps-ktimer.c')
-rw-r--r--drivers/pps/clients/pps-ktimer.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/drivers/pps/clients/pps-ktimer.c b/drivers/pps/clients/pps-ktimer.c
index e7ef5b8186d0..82583b0ff82d 100644
--- a/drivers/pps/clients/pps-ktimer.c
+++ b/drivers/pps/clients/pps-ktimer.c
@@ -19,6 +19,7 @@
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22 23
23#include <linux/kernel.h> 24#include <linux/kernel.h>
24#include <linux/module.h> 25#include <linux/module.h>
@@ -31,7 +32,7 @@
31 * Global variables 32 * Global variables
32 */ 33 */
33 34
34static int source; 35static struct pps_device *pps;
35static struct timer_list ktimer; 36static struct timer_list ktimer;
36 37
37/* 38/*
@@ -40,19 +41,12 @@ static struct timer_list ktimer;
40 41
41static void pps_ktimer_event(unsigned long ptr) 42static void pps_ktimer_event(unsigned long ptr)
42{ 43{
43 struct timespec __ts; 44 struct pps_event_time ts;
44 struct pps_ktime ts;
45 45
46 /* First of all we get the time stamp... */ 46 /* First of all we get the time stamp... */
47 getnstimeofday(&__ts); 47 pps_get_ts(&ts);
48 48
49 pr_info("PPS event at %lu\n", jiffies); 49 pps_event(pps, &ts, PPS_CAPTUREASSERT, NULL);
50
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);
56 50
57 mod_timer(&ktimer, jiffies + HZ); 51 mod_timer(&ktimer, jiffies + HZ);
58} 52}
@@ -61,12 +55,11 @@ static void pps_ktimer_event(unsigned long ptr)
61 * The echo function 55 * The echo function
62 */ 56 */
63 57
64static void pps_ktimer_echo(int source, int event, void *data) 58static void pps_ktimer_echo(struct pps_device *pps, int event, void *data)
65{ 59{
66 pr_info("echo %s %s for source %d\n", 60 dev_info(pps->dev, "echo %s %s\n",
67 event & PPS_CAPTUREASSERT ? "assert" : "", 61 event & PPS_CAPTUREASSERT ? "assert" : "",
68 event & PPS_CAPTURECLEAR ? "clear" : "", 62 event & PPS_CAPTURECLEAR ? "clear" : "");
69 source);
70} 63}
71 64
72/* 65/*
@@ -89,30 +82,27 @@ static struct pps_source_info pps_ktimer_info = {
89 82
90static void __exit pps_ktimer_exit(void) 83static void __exit pps_ktimer_exit(void)
91{ 84{
92 del_timer_sync(&ktimer); 85 dev_info(pps->dev, "ktimer PPS source unregistered\n");
93 pps_unregister_source(source);
94 86
95 pr_info("ktimer PPS source unregistered\n"); 87 del_timer_sync(&ktimer);
88 pps_unregister_source(pps);
96} 89}
97 90
98static int __init pps_ktimer_init(void) 91static int __init pps_ktimer_init(void)
99{ 92{
100 int ret; 93 pps = pps_register_source(&pps_ktimer_info,
101
102 ret = pps_register_source(&pps_ktimer_info,
103 PPS_CAPTUREASSERT | PPS_OFFSETASSERT); 94 PPS_CAPTUREASSERT | PPS_OFFSETASSERT);
104 if (ret < 0) { 95 if (pps == NULL) {
105 printk(KERN_ERR "cannot register ktimer source\n"); 96 pr_err("cannot register PPS source\n");
106 return ret; 97 return -ENOMEM;
107 } 98 }
108 source = ret;
109 99
110 setup_timer(&ktimer, pps_ktimer_event, 0); 100 setup_timer(&ktimer, pps_ktimer_event, 0);
111 mod_timer(&ktimer, jiffies + HZ); 101 mod_timer(&ktimer, jiffies + HZ);
112 102
113 pr_info("ktimer PPS source registered at %d\n", source); 103 dev_info(pps->dev, "ktimer PPS source registered\n");
114 104
115 return 0; 105 return 0;
116} 106}
117 107
118module_init(pps_ktimer_init); 108module_init(pps_ktimer_init);