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, 18 insertions, 26 deletions
diff --git a/drivers/pps/clients/pps-ktimer.c b/drivers/pps/clients/pps-ktimer.c
index e7ef5b8186d..2728469d388 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,14 @@ 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 dev_info(pps->dev, "PPS event at %lu\n", jiffies);
50 50
51 /* ... and translate it to PPS time data struct */ 51 pps_event(pps, &ts, PPS_CAPTUREASSERT, NULL);
52 ts.sec = __ts.tv_sec;
53 ts.nsec = __ts.tv_nsec;
54
55 pps_event(source, &ts, PPS_CAPTUREASSERT, NULL);
56 52
57 mod_timer(&ktimer, jiffies + HZ); 53 mod_timer(&ktimer, jiffies + HZ);
58} 54}
@@ -61,12 +57,11 @@ static void pps_ktimer_event(unsigned long ptr)
61 * The echo function 57 * The echo function
62 */ 58 */
63 59
64static void pps_ktimer_echo(int source, int event, void *data) 60static void pps_ktimer_echo(struct pps_device *pps, int event, void *data)
65{ 61{
66 pr_info("echo %s %s for source %d\n", 62 dev_info(pps->dev, "echo %s %s\n",
67 event & PPS_CAPTUREASSERT ? "assert" : "", 63 event & PPS_CAPTUREASSERT ? "assert" : "",
68 event & PPS_CAPTURECLEAR ? "clear" : "", 64 event & PPS_CAPTURECLEAR ? "clear" : "");
69 source);
70} 65}
71 66
72/* 67/*
@@ -89,30 +84,27 @@ static struct pps_source_info pps_ktimer_info = {
89 84
90static void __exit pps_ktimer_exit(void) 85static void __exit pps_ktimer_exit(void)
91{ 86{
92 del_timer_sync(&ktimer); 87 dev_info(pps->dev, "ktimer PPS source unregistered\n");
93 pps_unregister_source(source);
94 88
95 pr_info("ktimer PPS source unregistered\n"); 89 del_timer_sync(&ktimer);
90 pps_unregister_source(pps);
96} 91}
97 92
98static int __init pps_ktimer_init(void) 93static int __init pps_ktimer_init(void)
99{ 94{
100 int ret; 95 pps = pps_register_source(&pps_ktimer_info,
101
102 ret = pps_register_source(&pps_ktimer_info,
103 PPS_CAPTUREASSERT | PPS_OFFSETASSERT); 96 PPS_CAPTUREASSERT | PPS_OFFSETASSERT);
104 if (ret < 0) { 97 if (pps == NULL) {
105 printk(KERN_ERR "cannot register ktimer source\n"); 98 pr_err("cannot register PPS source\n");
106 return ret; 99 return -ENOMEM;
107 } 100 }
108 source = ret;
109 101
110 setup_timer(&ktimer, pps_ktimer_event, 0); 102 setup_timer(&ktimer, pps_ktimer_event, 0);
111 mod_timer(&ktimer, jiffies + HZ); 103 mod_timer(&ktimer, jiffies + HZ);
112 104
113 pr_info("ktimer PPS source registered at %d\n", source); 105 dev_info(pps->dev, "ktimer PPS source registered\n");
114 106
115 return 0; 107 return 0;
116} 108}
117 109
118module_init(pps_ktimer_init); 110module_init(pps_ktimer_init);