#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/uaccess.h>
#include <linux/pps_kernel.h>
static struct class *pps_class;
static DEFINE_MUTEX(pps_idr_lock);
static DEFINE_IDR(pps_idr);
static __poll_t pps_cdev_poll(struct file *file, poll_table *wait)
struct pps_device *pps = file->private_data;
poll_wait(file, &pps->queue, wait);
return EPOLLIN | EPOLLRDNORM;
static int pps_cdev_fasync(int fd, struct file *file, int on)
struct pps_device *pps = file->private_data;
return fasync_helper(fd, file, on, &pps->async_queue);
static int pps_cdev_pps_fetch(struct pps_device *pps, struct pps_fdata *fdata)
unsigned int ev = pps->last_ev;
if (fdata->timeout.flags & PPS_TIME_INVALID)
err = wait_event_interruptible(pps->queue,