aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pps/clients
diff options
context:
space:
mode:
authorRodolfo Giometti <giometti@linux.it>2010-03-10 18:23:45 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-12 18:52:43 -0500
commit697fb85fcf21b5229a3072440222d14b05ef2abe (patch)
tree9a40e480634584c3212a37d63b6e2eea7fa8f45d /drivers/pps/clients
parent51e7364ef281e540371f084008732b13292622f0 (diff)
pps: LinuxPPS clients support
Each PPS source can be registered/deregistered into the system by using special modules called "clients". They simply define the PPS sources' attributes and implement the time signal registration mechanism. This patch adds a special directory for such clients and adds a dummy client that can be useful to test system integrity on real systems. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Rodolfo Giometti <giometti@linux.it> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Greg KH <greg@kroah.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Alexander Gordeev <lasaine@lvk.cs.msu.su> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pps/clients')
-rw-r--r--drivers/pps/clients/Kconfig18
-rw-r--r--drivers/pps/clients/Makefile9
-rw-r--r--drivers/pps/clients/pps-ktimer.c123
3 files changed, 150 insertions, 0 deletions
diff --git a/drivers/pps/clients/Kconfig b/drivers/pps/clients/Kconfig
new file mode 100644
index 000000000000..43ccd3b644f0
--- /dev/null
+++ b/drivers/pps/clients/Kconfig
@@ -0,0 +1,18 @@
1#
2# PPS clients configuration
3#
4
5if PPS
6
7comment "PPS clients support"
8
9config PPS_CLIENT_KTIMER
10 tristate "Kernel timer client (Testing client, use for debug)"
11 help
12 If you say yes here you get support for a PPS debugging client
13 which uses a kernel timer to generate the PPS signal.
14
15 This driver can also be built as a module. If so, the module
16 will be called pps-ktimer.
17
18endif
diff --git a/drivers/pps/clients/Makefile b/drivers/pps/clients/Makefile
new file mode 100644
index 000000000000..115572ae3e99
--- /dev/null
+++ b/drivers/pps/clients/Makefile
@@ -0,0 +1,9 @@
1#
2# Makefile for PPS clients.
3#
4
5obj-$(CONFIG_PPS_CLIENT_KTIMER) += pps-ktimer.o
6
7ifeq ($(CONFIG_PPS_DEBUG),y)
8EXTRA_CFLAGS += -DDEBUG
9endif
diff --git a/drivers/pps/clients/pps-ktimer.c b/drivers/pps/clients/pps-ktimer.c
new file mode 100644
index 000000000000..e7ef5b8186d0
--- /dev/null
+++ b/drivers/pps/clients/pps-ktimer.c
@@ -0,0 +1,123 @@
1/*
2 * pps-ktimer.c -- kernel timer test client
3 *
4 *
5 * Copyright (C) 2005-2006 Rodolfo Giometti <giometti@linux.it>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/time.h>
27#include <linux/timer.h>
28#include <linux/pps_kernel.h>
29
30/*
31 * Global variables
32 */
33
34static int source;
35static struct timer_list ktimer;
36
37/*
38 * The kernel timer
39 */
40
41static void pps_ktimer_event(unsigned long ptr)
42{
43 struct timespec __ts;
44 struct pps_ktime ts;
45
46 /* First of all we get the time stamp... */
47 getnstimeofday(&__ts);
48
49 pr_info("PPS event at %lu\n", jiffies);
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
57 mod_timer(&ktimer, jiffies + HZ);
58}
59
60/*
61 * The echo function
62 */
63
64static void pps_ktimer_echo(int source, int event, void *data)
65{
66 pr_info("echo %s %s for source %d\n",
67 event & PPS_CAPTUREASSERT ? "assert" : "",
68 event & PPS_CAPTURECLEAR ? "clear" : "",
69 source);
70}
71
72/*
73 * The PPS info struct
74 */
75
76static struct pps_source_info pps_ktimer_info = {
77 .name = "ktimer",
78 .path = "",
79 .mode = PPS_CAPTUREASSERT | PPS_OFFSETASSERT |
80 PPS_ECHOASSERT |
81 PPS_CANWAIT | PPS_TSFMT_TSPEC,
82 .echo = pps_ktimer_echo,
83 .owner = THIS_MODULE,
84};
85
86/*
87 * Module staff
88 */
89
90static void __exit pps_ktimer_exit(void)
91{
92 del_timer_sync(&ktimer);
93 pps_unregister_source(source);
94
95 pr_info("ktimer PPS source unregistered\n");
96}
97
98static int __init pps_ktimer_init(void)
99{
100 int ret;
101
102 ret = pps_register_source(&pps_ktimer_info,
103 PPS_CAPTUREASSERT | PPS_OFFSETASSERT);
104 if (ret < 0) {
105 printk(KERN_ERR "cannot register ktimer source\n");
106 return ret;
107 }
108 source = ret;
109
110 setup_timer(&ktimer, pps_ktimer_event, 0);
111 mod_timer(&ktimer, jiffies + HZ);
112
113 pr_info("ktimer PPS source registered at %d\n", source);
114
115 return 0;
116}
117
118module_init(pps_ktimer_init);
119module_exit(pps_ktimer_exit);
120
121MODULE_AUTHOR("Rodolfo Giometti <giometti@linux.it>");
122MODULE_DESCRIPTION("dummy PPS source by using a kernel timer (just for debug)");
123MODULE_LICENSE("GPL");