Lines Matching full:pps
41 static void pps_echo_client_default(struct pps_device *pps, int event, in pps_echo_client_default() argument
44 dev_info(pps->dev, "echo %s %s\n", in pps_echo_client_default()
53 /* pps_register_source - add a PPS source in the system
54 * @info: the PPS info struct
55 * @default_params: the default PPS parameters of the new source
57 * This function is used to add a new PPS source in the system. The new
58 * source is described by info's fields and it will have, as default PPS
61 * The function returns, in case of success, the PPS device. Otherwise
68 struct pps_device *pps; in pps_register_source() local
85 /* Allocate memory for the new PPS source struct */ in pps_register_source()
86 pps = kzalloc(sizeof(struct pps_device), GFP_KERNEL); in pps_register_source()
87 if (pps == NULL) { in pps_register_source()
95 pps->params.api_version = PPS_API_VERS; in pps_register_source()
96 pps->params.mode = default_params; in pps_register_source()
97 pps->info = *info; in pps_register_source()
100 if ((pps->info.mode & (PPS_ECHOASSERT | PPS_ECHOCLEAR)) && in pps_register_source()
101 pps->info.echo == NULL) in pps_register_source()
102 pps->info.echo = pps_echo_client_default; in pps_register_source()
104 init_waitqueue_head(&pps->queue); in pps_register_source()
105 spin_lock_init(&pps->lock); in pps_register_source()
108 err = pps_register_cdev(pps); in pps_register_source()
115 dev_info(pps->dev, "new PPS source %s\n", info->name); in pps_register_source()
117 return pps; in pps_register_source()
120 kfree(pps); in pps_register_source()
129 /* pps_unregister_source - remove a PPS source from the system
130 * @pps: the PPS source
132 * This function is used to remove a previously registered PPS source from
136 void pps_unregister_source(struct pps_device *pps) in pps_unregister_source() argument
138 pps_kc_remove(pps); in pps_unregister_source()
139 pps_unregister_cdev(pps); in pps_unregister_source()
141 /* don't have to kfree(pps) here because it will be done on in pps_unregister_source()
146 /* pps_event - register a PPS event into the system
147 * @pps: the PPS device
152 * This function is used by each PPS client in order to register a new
153 * PPS event into the system (it's usually called inside an IRQ handler).
155 * If an echo function is associated with the PPS device it will be called
157 * pps->info.echo(pps, event, data);
159 void pps_event(struct pps_device *pps, struct pps_event_time *ts, int event, in pps_event() argument
169 dev_dbg(pps->dev, "PPS event at %lld.%09ld\n", in pps_event()
174 spin_lock_irqsave(&pps->lock, flags); in pps_event()
177 if ((pps->params.mode & (PPS_ECHOASSERT | PPS_ECHOCLEAR))) in pps_event()
178 pps->info.echo(pps, event, data); in pps_event()
181 pps->current_mode = pps->params.mode; in pps_event()
182 if (event & pps->params.mode & PPS_CAPTUREASSERT) { in pps_event()
184 if (pps->params.mode & PPS_OFFSETASSERT) in pps_event()
186 &pps->params.assert_off_tu); in pps_event()
189 pps->assert_tu = ts_real; in pps_event()
190 pps->assert_sequence++; in pps_event()
191 dev_dbg(pps->dev, "capture assert seq #%u\n", in pps_event()
192 pps->assert_sequence); in pps_event()
196 if (event & pps->params.mode & PPS_CAPTURECLEAR) { in pps_event()
198 if (pps->params.mode & PPS_OFFSETCLEAR) in pps_event()
200 &pps->params.clear_off_tu); in pps_event()
203 pps->clear_tu = ts_real; in pps_event()
204 pps->clear_sequence++; in pps_event()
205 dev_dbg(pps->dev, "capture clear seq #%u\n", in pps_event()
206 pps->clear_sequence); in pps_event()
211 pps_kc_event(pps, ts, event); in pps_event()
215 pps->last_ev++; in pps_event()
216 wake_up_interruptible_all(&pps->queue); in pps_event()
218 kill_fasync(&pps->async_queue, SIGIO, POLL_IN); in pps_event()
221 spin_unlock_irqrestore(&pps->lock, flags); in pps_event()