Lines Matching full:pps

3  * PPS core file
40 struct pps_device *pps = file->private_data; in pps_cdev_poll() local
42 poll_wait(file, &pps->queue, wait); in pps_cdev_poll()
49 struct pps_device *pps = file->private_data; in pps_cdev_fasync() local
50 return fasync_helper(fd, file, on, &pps->async_queue); in pps_cdev_fasync()
53 static int pps_cdev_pps_fetch(struct pps_device *pps, struct pps_fdata *fdata) in pps_cdev_pps_fetch() argument
55 unsigned int ev = pps->last_ev; in pps_cdev_pps_fetch()
60 err = wait_event_interruptible(pps->queue, in pps_cdev_pps_fetch()
61 ev != pps->last_ev); in pps_cdev_pps_fetch()
65 dev_dbg(pps->dev, "timeout %lld.%09d\n", in pps_cdev_pps_fetch()
73 pps->queue, in pps_cdev_pps_fetch()
74 ev != pps->last_ev, in pps_cdev_pps_fetch()
83 dev_dbg(pps->dev, "pending signal caught\n"); in pps_cdev_pps_fetch()
93 struct pps_device *pps = file->private_data; in pps_cdev_ioctl() local
101 dev_dbg(pps->dev, "PPS_GETPARAMS\n"); in pps_cdev_ioctl()
103 spin_lock_irq(&pps->lock); in pps_cdev_ioctl()
106 params = pps->params; in pps_cdev_ioctl()
108 spin_unlock_irq(&pps->lock); in pps_cdev_ioctl()
117 dev_dbg(pps->dev, "PPS_SETPARAMS\n"); in pps_cdev_ioctl()
127 dev_dbg(pps->dev, "capture mode unspecified (%x)\n", in pps_cdev_ioctl()
133 if ((params.mode & ~pps->info.mode) != 0) { in pps_cdev_ioctl()
134 dev_dbg(pps->dev, "unsupported capabilities (%x)\n", in pps_cdev_ioctl()
139 spin_lock_irq(&pps->lock); in pps_cdev_ioctl()
142 pps->params = params; in pps_cdev_ioctl()
147 dev_dbg(pps->dev, "time format unspecified (%x)\n", in pps_cdev_ioctl()
149 pps->params.mode |= PPS_TSFMT_TSPEC; in pps_cdev_ioctl()
151 if (pps->info.mode & PPS_CANWAIT) in pps_cdev_ioctl()
152 pps->params.mode |= PPS_CANWAIT; in pps_cdev_ioctl()
153 pps->params.api_version = PPS_API_VERS; in pps_cdev_ioctl()
160 pps->params.assert_off_tu.flags = 0; in pps_cdev_ioctl()
161 pps->params.clear_off_tu.flags = 0; in pps_cdev_ioctl()
163 spin_unlock_irq(&pps->lock); in pps_cdev_ioctl()
168 dev_dbg(pps->dev, "PPS_GETCAP\n"); in pps_cdev_ioctl()
170 err = put_user(pps->info.mode, iuarg); in pps_cdev_ioctl()
179 dev_dbg(pps->dev, "PPS_FETCH\n"); in pps_cdev_ioctl()
185 err = pps_cdev_pps_fetch(pps, &fdata); in pps_cdev_ioctl()
190 spin_lock_irq(&pps->lock); in pps_cdev_ioctl()
192 fdata.info.assert_sequence = pps->assert_sequence; in pps_cdev_ioctl()
193 fdata.info.clear_sequence = pps->clear_sequence; in pps_cdev_ioctl()
194 fdata.info.assert_tu = pps->assert_tu; in pps_cdev_ioctl()
195 fdata.info.clear_tu = pps->clear_tu; in pps_cdev_ioctl()
196 fdata.info.current_mode = pps->current_mode; in pps_cdev_ioctl()
198 spin_unlock_irq(&pps->lock); in pps_cdev_ioctl()
209 dev_dbg(pps->dev, "PPS_KC_BIND\n"); in pps_cdev_ioctl()
220 if ((bind_args.edge & ~pps->info.mode) != 0) { in pps_cdev_ioctl()
221 dev_err(pps->dev, "unsupported capabilities (%x)\n", in pps_cdev_ioctl()
230 dev_err(pps->dev, "invalid kernel consumer bind" in pps_cdev_ioctl()
235 err = pps_kc_bind(pps, &bind_args); in pps_cdev_ioctl()
252 struct pps_device *pps = file->private_data; in pps_cdev_compat_ioctl() local
262 dev_dbg(pps->dev, "PPS_FETCH\n"); in pps_cdev_compat_ioctl()
271 err = pps_cdev_pps_fetch(pps, &fdata); in pps_cdev_compat_ioctl()
276 spin_lock_irq(&pps->lock); in pps_cdev_compat_ioctl()
278 compat.info.assert_sequence = pps->assert_sequence; in pps_cdev_compat_ioctl()
279 compat.info.clear_sequence = pps->clear_sequence; in pps_cdev_compat_ioctl()
280 compat.info.current_mode = pps->current_mode; in pps_cdev_compat_ioctl()
282 memcpy(&compat.info.assert_tu, &pps->assert_tu, in pps_cdev_compat_ioctl()
284 memcpy(&compat.info.clear_tu, &pps->clear_tu, in pps_cdev_compat_ioctl()
287 spin_unlock_irq(&pps->lock); in pps_cdev_compat_ioctl()
301 struct pps_device *pps = container_of(inode->i_cdev, in pps_cdev_open() local
303 file->private_data = pps; in pps_cdev_open()
304 kobject_get(&pps->dev->kobj); in pps_cdev_open()
310 struct pps_device *pps = container_of(inode->i_cdev, in pps_cdev_release() local
312 kobject_put(&pps->dev->kobj); in pps_cdev_release()
333 struct pps_device *pps = dev_get_drvdata(dev); in pps_device_destruct() local
335 cdev_del(&pps->cdev); in pps_device_destruct()
338 pr_debug("deallocating pps%d\n", pps->id); in pps_device_destruct()
340 idr_remove(&pps_idr, pps->id); in pps_device_destruct()
344 kfree(pps); in pps_device_destruct()
347 int pps_register_cdev(struct pps_device *pps) in pps_register_cdev() argument
354 * Get new ID for the new PPS source. After idr_alloc() calling in pps_register_cdev()
357 err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL); in pps_register_cdev()
360 pr_err("%s: too many PPS sources in the system\n", in pps_register_cdev()
361 pps->info.name); in pps_register_cdev()
366 pps->id = err; in pps_register_cdev()
369 devt = MKDEV(MAJOR(pps_devt), pps->id); in pps_register_cdev()
371 cdev_init(&pps->cdev, &pps_cdev_fops); in pps_register_cdev()
372 pps->cdev.owner = pps->info.owner; in pps_register_cdev()
374 err = cdev_add(&pps->cdev, devt, 1); in pps_register_cdev()
377 pps->info.name, MAJOR(pps_devt), pps->id); in pps_register_cdev()
380 pps->dev = device_create(pps_class, pps->info.dev, devt, pps, in pps_register_cdev()
381 "pps%d", pps->id); in pps_register_cdev()
382 if (IS_ERR(pps->dev)) { in pps_register_cdev()
383 err = PTR_ERR(pps->dev); in pps_register_cdev()
388 pps->dev->release = pps_device_destruct; in pps_register_cdev()
390 pr_debug("source %s got cdev (%d:%d)\n", pps->info.name, in pps_register_cdev()
391 MAJOR(pps_devt), pps->id); in pps_register_cdev()
396 cdev_del(&pps->cdev); in pps_register_cdev()
400 idr_remove(&pps_idr, pps->id); in pps_register_cdev()
406 void pps_unregister_cdev(struct pps_device *pps) in pps_unregister_cdev() argument
408 pr_debug("unregistering pps%d\n", pps->id); in pps_unregister_cdev()
409 pps->lookup_cookie = NULL; in pps_unregister_cdev()
410 device_destroy(pps_class, pps->dev->devt); in pps_unregister_cdev()
414 * Look up a pps device by magic cookie.
418 * This is a bit of a kludge that is currently used only by the PPS
423 * It's initialized to NULL when the pps device is created, and if a
427 * so that it will not be used again, even if the pps device cannot
433 struct pps_device *pps; in pps_lookup_dev() local
437 idr_for_each_entry(&pps_idr, pps, id) in pps_lookup_dev()
438 if (cookie == pps->lookup_cookie) in pps_lookup_dev()
441 return pps; in pps_lookup_dev()
459 pps_class = class_create(THIS_MODULE, "pps"); in pps_init()
466 err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps"); in pps_init()