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.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/drivers/pps/clients/pps-ktimer.c b/drivers/pps/clients/pps-ktimer.c
index e1bdd8bc8c9c..966ead188ee2 100644
--- a/drivers/pps/clients/pps-ktimer.c
+++ b/drivers/pps/clients/pps-ktimer.c
@@ -31,7 +31,7 @@
31 * Global variables 31 * Global variables
32 */ 32 */
33 33
34static int source; 34static struct pps_device *pps;
35static struct timer_list ktimer; 35static struct timer_list ktimer;
36 36
37/* 37/*
@@ -47,7 +47,7 @@ static void pps_ktimer_event(unsigned long ptr)
47 47
48 pr_info("PPS event at %lu\n", jiffies); 48 pr_info("PPS event at %lu\n", jiffies);
49 49
50 pps_event(source, &ts, PPS_CAPTUREASSERT, NULL); 50 pps_event(pps, &ts, PPS_CAPTUREASSERT, NULL);
51 51
52 mod_timer(&ktimer, jiffies + HZ); 52 mod_timer(&ktimer, jiffies + HZ);
53} 53}
@@ -56,12 +56,11 @@ static void pps_ktimer_event(unsigned long ptr)
56 * The echo function 56 * The echo function
57 */ 57 */
58 58
59static void pps_ktimer_echo(int source, int event, void *data) 59static void pps_ktimer_echo(struct pps_device *pps, int event, void *data)
60{ 60{
61 pr_info("echo %s %s for source %d\n", 61 dev_info(pps->dev, "echo %s %s\n",
62 event & PPS_CAPTUREASSERT ? "assert" : "", 62 event & PPS_CAPTUREASSERT ? "assert" : "",
63 event & PPS_CAPTURECLEAR ? "clear" : "", 63 event & PPS_CAPTURECLEAR ? "clear" : "");
64 source);
65} 64}
66 65
67/* 66/*
@@ -84,30 +83,27 @@ static struct pps_source_info pps_ktimer_info = {
84 83
85static void __exit pps_ktimer_exit(void) 84static void __exit pps_ktimer_exit(void)
86{ 85{
87 del_timer_sync(&ktimer); 86 dev_info(pps->dev, "ktimer PPS source unregistered\n");
88 pps_unregister_source(source);
89 87
90 pr_info("ktimer PPS source unregistered\n"); 88 del_timer_sync(&ktimer);
89 pps_unregister_source(pps);
91} 90}
92 91
93static int __init pps_ktimer_init(void) 92static int __init pps_ktimer_init(void)
94{ 93{
95 int ret; 94 pps = pps_register_source(&pps_ktimer_info,
96
97 ret = pps_register_source(&pps_ktimer_info,
98 PPS_CAPTUREASSERT | PPS_OFFSETASSERT); 95 PPS_CAPTUREASSERT | PPS_OFFSETASSERT);
99 if (ret < 0) { 96 if (pps == NULL) {
100 printk(KERN_ERR "cannot register ktimer source\n"); 97 printk(KERN_ERR "cannot register ktimer source\n");
101 return ret; 98 return -ENOMEM;
102 } 99 }
103 source = ret;
104 100
105 setup_timer(&ktimer, pps_ktimer_event, 0); 101 setup_timer(&ktimer, pps_ktimer_event, 0);
106 mod_timer(&ktimer, jiffies + HZ); 102 mod_timer(&ktimer, jiffies + HZ);
107 103
108 pr_info("ktimer PPS source registered at %d\n", source); 104 dev_info(pps->dev, "ktimer PPS source registered\n");
109 105
110 return 0; 106 return 0;
111} 107}
112 108
113module_init(pps_ktimer_init); 109module_init(pps_ktimer_init);