With this, we can request the underlying driver to count the number of events that have been captured.
Signed-off-by: Felipe Balbi <felipe.ba...@linux.intel.com> --- drivers/ptp/ptp_chardev.c | 15 +++++++++++++++ include/uapi/linux/ptp_clock.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c index 18ffe449efdf..a3e163a6acdc 100644 --- a/drivers/ptp/ptp_chardev.c +++ b/drivers/ptp/ptp_chardev.c @@ -114,6 +114,7 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) struct system_device_crosststamp xtstamp; struct ptp_clock_info *ops = ptp->info; struct ptp_sys_offset *sysoff = NULL; + struct ptp_event_count_tstamp counttstamp; struct ptp_system_timestamp sts; struct ptp_clock_request req; struct ptp_clock_caps caps; @@ -301,6 +302,20 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) mutex_unlock(&ptp->pincfg_mux); break; + case PTP_EVENT_COUNT_TSTAMP: + if (!ops->counttstamp) + return -ENOTSUPP; + if (copy_from_user(&req.perout, (void __user *)arg, + sizeof(counttstamp))) { + err = -EFAULT; + break; + } + err = ops->counttstamp(ops, &counttstamp); + if (!err && copy_to_user((void __user *)arg, &counttstamp, + sizeof(counttstamp))) + err = -EFAULT; + break; + default: err = -ENOTTY; break; diff --git a/include/uapi/linux/ptp_clock.h b/include/uapi/linux/ptp_clock.h index 1bc794ad957a..674db7de64f3 100644 --- a/include/uapi/linux/ptp_clock.h +++ b/include/uapi/linux/ptp_clock.h @@ -148,6 +148,8 @@ struct ptp_pin_desc { _IOWR(PTP_CLK_MAGIC, 8, struct ptp_sys_offset_precise) #define PTP_SYS_OFFSET_EXTENDED \ _IOWR(PTP_CLK_MAGIC, 9, struct ptp_sys_offset_extended) +#define PTP_EVENT_COUNT_TSTAMP \ + _IOWR(PTP_CLK_MAGIC, 6, struct ptp_event_count_tstamp) struct ptp_extts_event { struct ptp_clock_time t; /* Time event occured. */ -- 2.22.0