Lines Matching refs:pps
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 = container_of(inode->i_cdev,
303 file->private_data = pps;
304 kobject_get(&pps->dev->kobj);
310 struct pps_device *pps = container_of(inode->i_cdev,
312 kobject_put(&pps->dev->kobj);
333 struct pps_device *pps = dev_get_drvdata(dev);
335 cdev_del(&pps->cdev);
338 pr_debug("deallocating pps%d\n", pps->id);
340 idr_remove(&pps_idr, pps->id);
344 kfree(pps);
347 int pps_register_cdev(struct pps_device *pps)
357 err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL);
361 pps->info.name);
366 pps->id = err;
369 devt = MKDEV(MAJOR(pps_devt), pps->id);
371 cdev_init(&pps->cdev, &pps_cdev_fops);
372 pps->cdev.owner = pps->info.owner;
374 err = cdev_add(&pps->cdev, devt, 1);
377 pps->info.name, MAJOR(pps_devt), pps->id);
380 pps->dev = device_create(pps_class, pps->info.dev, devt, pps,
381 "pps%d", pps->id);
382 if (IS_ERR(pps->dev)) {
383 err = PTR_ERR(pps->dev);
388 pps->dev->release = pps_device_destruct;
390 pr_debug("source %s got cdev (%d:%d)\n", pps->info.name,
391 MAJOR(pps_devt), pps->id);
396 cdev_del(&pps->cdev);
400 idr_remove(&pps_idr, pps->id);
406 void pps_unregister_cdev(struct pps_device *pps)
408 pr_debug("unregistering pps%d\n", pps->id);
409 pps->lookup_cookie = NULL;
410 device_destroy(pps_class, pps->dev->devt);
414 * Look up a pps device by magic cookie.
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;
437 idr_for_each_entry(&pps_idr, pps, id)
438 if (cookie == pps->lookup_cookie)
441 return pps;
459 pps_class = class_create("pps");
466 err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps");