22 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24 #include <linux/kernel.h>
25 #include <linux/module.h>
27 #include <linux/sched.h>
32 #include <linux/poll.h>
34 #include <linux/slab.h>
42 static dev_t pps_devt;
43 static struct class *pps_class;
56 poll_wait(file, &pps->
queue, wait);
61 static int pps_cdev_fasync(
int fd,
struct file *
file,
int on)
67 static long pps_cdev_ioctl(
struct file *
file,
68 unsigned int cmd,
unsigned long arg)
80 spin_lock_irq(&pps->
lock);
85 spin_unlock_irq(&pps->
lock);
104 dev_dbg(pps->
dev,
"capture mode unspecified (%x)\n",
111 dev_dbg(pps->
dev,
"unsupported capabilities (%x)\n",
116 spin_lock_irq(&pps->
lock);
124 dev_dbg(pps->
dev,
"time format unspecified (%x)\n",
132 spin_unlock_irq(&pps->
lock);
165 (
long long) fdata.timeout.sec,
167 ticks = fdata.timeout.sec *
HZ;
187 spin_lock_irq(&pps->
lock);
192 fdata.info.clear_tu = pps->
clear_tu;
195 spin_unlock_irq(&pps->
lock);
217 if ((bind_args.edge & ~pps->
info.mode) != 0) {
218 dev_err(pps->
dev,
"unsupported capabilities (%x)\n",
227 dev_err(pps->
dev,
"invalid kernel consumer bind"
228 " parameters (%x)\n", bind_args.edge);
245 static int pps_cdev_open(
struct inode *
inode,
struct file *file)
254 static int pps_cdev_release(
struct inode *
inode,
struct file *file)
266 .poll = pps_cdev_poll,
267 .fasync = pps_cdev_fasync,
268 .unlocked_ioctl = pps_cdev_ioctl,
269 .open = pps_cdev_open,
270 .release = pps_cdev_release,
273 static void pps_device_destruct(
struct device *
dev)
311 pr_err(
"%s: too many PPS sources in the system\n",
324 pr_err(
"%s: failed to add char device %d:%d\n",
330 if (IS_ERR(pps->
dev)) {
331 err = PTR_ERR(pps->
dev);
335 pps->
dev->release = pps_device_destruct;
337 pr_debug(
"source %s got cdev (%d:%d)\n", pps->
info.name,
363 static void __exit pps_exit(
void)
369 static int __init pps_init(
void)
374 if (IS_ERR(pps_class)) {
375 pr_err(
"failed to allocate class\n");
376 return PTR_ERR(pps_class);
382 pr_err(
"failed to allocate char device region\n");
387 pr_info(
"Software ver. %s - Copyright 2005-2007 Rodolfo Giometti "