Lines Matching full:pps
3 * PPS core file
40 struct pps_device *pps = file->private_data;
42 poll_wait(file, &pps->queue, wait);
49 struct pps_device *pps = file->private_data;
50 return fasync_helper(fd, file, on, &pps->async_queue);
53 static int pps_cdev_pps_fetch(struct pps_device *pps, struct pps_fdata *fdata)
55 unsigned int ev = pps->last_ev;
60 err = wait_event_interruptible(pps->queue,
61 ev != pps->last_ev);
65 dev_dbg(&pps->dev, "timeout %lld.%09d\n",
73 pps->queue,
74 ev != pps->last_ev,
83 dev_dbg(&pps->dev, "pending signal caught\n");
93 struct pps_device *pps = file->private_data;
101 dev_dbg(&pps->dev, "PPS_GETPARAMS\n");
103 spin_lock_irq(&pps->lock);
106 params = pps->params;
108 spin_unlock_irq(&pps->lock);
117 dev_dbg(&pps->dev, "PPS_SETPARAMS\n");
127 dev_dbg(&pps->dev, "capture mode unspecified (%x)\n",
133 if ((params.mode & ~pps->info.mode) != 0) {
134 dev_dbg(&pps->dev, "unsupported capabilities (%x)\n",
139 spin_lock_irq(&pps->lock);
142 pps->params = params;
147 dev_dbg(&pps->dev, "time format unspecified (%x)\n",
149 pps->params.mode |= PPS_TSFMT_TSPEC;
151 if (pps->info.mode & PPS_CANWAIT)
152 pps->params.mode |= PPS_CANWAIT;
153 pps->params.api_version = PPS_API_VERS;
160 pps->params.assert_off_tu.flags = 0;
161 pps->params.clear_off_tu.flags = 0;
163 spin_unlock_irq(&pps->lock);
168 dev_dbg(&pps->dev, "PPS_GETCAP\n");
170 err = put_user(pps->info.mode, iuarg);
179 dev_dbg(&pps->dev, "PPS_FETCH\n");
185 err = pps_cdev_pps_fetch(pps, &fdata);
190 spin_lock_irq(&pps->lock);
192 fdata.info.assert_sequence = pps->assert_sequence;
193 fdata.info.clear_sequence = pps->clear_sequence;
194 fdata.info.assert_tu = pps->assert_tu;
195 fdata.info.clear_tu = pps->clear_tu;
196 fdata.info.current_mode = pps->current_mode;
198 spin_unlock_irq(&pps->lock);
209 dev_dbg(&pps->dev, "PPS_KC_BIND\n");
220 if ((bind_args.edge & ~pps->info.mode) != 0) {
221 dev_err(&pps->dev, "unsupported capabilities (%x)\n",
230 dev_err(&pps->dev, "invalid kernel consumer bind"
235 err = pps_kc_bind(pps, &bind_args);
252 struct pps_device *pps = file->private_data;
262 dev_dbg(&pps->dev, "PPS_FETCH\n");
271 err = pps_cdev_pps_fetch(pps, &fdata);
276 spin_lock_irq(&pps->lock);
278 compat.info.assert_sequence = pps->assert_sequence;
279 compat.info.clear_sequence = pps->clear_sequence;
280 compat.info.current_mode = pps->current_mode;
282 memcpy(&compat.info.assert_tu, &pps->assert_tu,
284 memcpy(&compat.info.clear_tu, &pps->clear_tu,
287 spin_unlock_irq(&pps->lock);
301 struct pps_device *pps;
304 pps = idr_find(&pps_idr, id);
305 if (pps)
306 get_device(&pps->dev);
309 return pps;
314 struct pps_device *pps = pps_idr_get(iminor(inode));
316 if (!pps)
319 file->private_data = pps;
325 struct pps_device *pps = file->private_data;
327 WARN_ON(pps->id != iminor(inode));
328 put_device(&pps->dev);
348 struct pps_device *pps = dev_get_drvdata(dev);
350 pr_debug("deallocating pps%d\n", pps->id);
351 kfree(pps);
354 int pps_register_cdev(struct pps_device *pps)
360 * Get new ID for the new PPS source. After idr_alloc() calling
363 err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL);
366 pr_err("%s: too many PPS sources in the system\n",
367 pps->info.name);
372 pps->id = err;
374 pps->dev.class = pps_class;
375 pps->dev.parent = pps->info.dev;
376 pps->dev.devt = MKDEV(pps_major, pps->id);
377 dev_set_drvdata(&pps->dev, pps);
378 dev_set_name(&pps->dev, "pps%d", pps->id);
379 err = device_register(&pps->dev);
384 pps->dev.release = pps_device_destruct;
386 pr_debug("source %s got cdev (%d:%d)\n", pps->info.name, pps_major,
387 pps->id);
389 get_device(&pps->dev);
394 idr_remove(&pps_idr, pps->id);
395 put_device(&pps->dev);
401 void pps_unregister_cdev(struct pps_device *pps)
403 pr_debug("unregistering pps%d\n", pps->id);
404 pps->lookup_cookie = NULL;
405 device_destroy(pps_class, pps->dev.devt);
409 idr_remove(&pps_idr, pps->id);
410 put_device(&pps->dev);
415 * Look up a pps device by magic cookie.
419 * This is a bit of a kludge that is currently used only by the PPS
424 * It's initialized to NULL when the pps device is created, and if a
428 * so that it will not be used again, even if the pps device cannot
439 struct pps_device *pps;
443 idr_for_each_entry(&pps_idr, pps, id)
444 if (cookie == pps->lookup_cookie)
447 return pps;
458 __unregister_chrdev(pps_major, 0, PPS_MAX_SOURCES, "pps");
463 pps_class = class_create("pps");
470 pps_major = __register_chrdev(0, 0, PPS_MAX_SOURCES, "pps",