This source file includes following definitions.
- timespec_to_pps_ktime
- pps_get_ts
- pps_sub_ts
1
2
3
4
5
6
7
8 #ifndef LINUX_PPS_KERNEL_H
9 #define LINUX_PPS_KERNEL_H
10
11 #include <linux/pps.h>
12 #include <linux/cdev.h>
13 #include <linux/device.h>
14 #include <linux/time.h>
15
16
17
18
19
20 struct pps_device;
21
22
23 struct pps_source_info {
24 char name[PPS_MAX_NAME_LEN];
25 char path[PPS_MAX_NAME_LEN];
26 int mode;
27
28 void (*echo)(struct pps_device *pps,
29 int event, void *data);
30
31 struct module *owner;
32 struct device *dev;
33 };
34
35 struct pps_event_time {
36 #ifdef CONFIG_NTP_PPS
37 struct timespec64 ts_raw;
38 #endif
39 struct timespec64 ts_real;
40 };
41
42
43 struct pps_device {
44 struct pps_source_info info;
45
46 struct pps_kparams params;
47
48 __u32 assert_sequence;
49 __u32 clear_sequence;
50 struct pps_ktime assert_tu;
51 struct pps_ktime clear_tu;
52 int current_mode;
53
54 unsigned int last_ev;
55 wait_queue_head_t queue;
56
57 unsigned int id;
58 void const *lookup_cookie;
59 struct cdev cdev;
60 struct device *dev;
61 struct fasync_struct *async_queue;
62 spinlock_t lock;
63 };
64
65
66
67
68
69 extern const struct attribute_group *pps_groups[];
70
71
72
73
74
75
76
77
78 extern int pps_register_cdev(struct pps_device *pps);
79 extern void pps_unregister_cdev(struct pps_device *pps);
80
81
82
83
84
85 extern struct pps_device *pps_register_source(
86 struct pps_source_info *info, int default_params);
87 extern void pps_unregister_source(struct pps_device *pps);
88 extern void pps_event(struct pps_device *pps,
89 struct pps_event_time *ts, int event, void *data);
90
91 struct pps_device *pps_lookup_dev(void const *cookie);
92
93 static inline void timespec_to_pps_ktime(struct pps_ktime *kt,
94 struct timespec64 ts)
95 {
96 kt->sec = ts.tv_sec;
97 kt->nsec = ts.tv_nsec;
98 }
99
100 static inline void pps_get_ts(struct pps_event_time *ts)
101 {
102 struct system_time_snapshot snap;
103
104 ktime_get_snapshot(&snap);
105 ts->ts_real = ktime_to_timespec64(snap.real);
106 #ifdef CONFIG_NTP_PPS
107 ts->ts_raw = ktime_to_timespec64(snap.raw);
108 #endif
109 }
110
111
112 static inline void pps_sub_ts(struct pps_event_time *ts, struct timespec64 delta)
113 {
114 ts->ts_real = timespec64_sub(ts->ts_real, delta);
115 #ifdef CONFIG_NTP_PPS
116 ts->ts_raw = timespec64_sub(ts->ts_raw, delta);
117 #endif
118 }
119
120 #endif