From: Felipe Balbi <felipe.balbi@linux.intel.com>
To: Richard Cochran <richardcochran@gmail.com>
Cc: netdev@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H . Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
"Christopher S . Hall" <christopher.s.hall@intel.com>,
Felipe Balbi <felipe.balbi@linux.intel.com>
Subject: [RFC PATCH 3/5] PTP: implement PTP_EVENT_COUNT_TSTAMP ioctl
Date: Tue, 16 Jul 2019 10:20:36 +0300 [thread overview]
Message-ID: <20190716072038.8408-4-felipe.balbi@linux.intel.com> (raw)
In-Reply-To: <20190716072038.8408-1-felipe.balbi@linux.intel.com>
With this, we can request the underlying driver to count the number of
events that have been captured.
Signed-off-by: Felipe Balbi <felipe.balbi@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
next prev parent reply other threads:[~2019-07-16 7:21 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-16 7:20 [RFC PATCH 0/5] PTP: add support for Intel's TGPIO controller Felipe Balbi
2019-07-16 7:20 ` [RFC PATCH 1/5] x86: tsc: add tsc to art helpers Felipe Balbi
2019-07-16 7:57 ` Thomas Gleixner
2019-08-15 5:57 ` Felipe Balbi
2019-08-15 14:16 ` Thomas Gleixner
2019-10-01 10:24 ` Felipe Balbi
2019-10-17 11:15 ` Thomas Gleixner
2019-10-17 12:01 ` Felipe Balbi
2019-07-16 7:20 ` [RFC PATCH 2/5] PTP: add a callback for counting timestamp events Felipe Balbi
2019-07-16 7:20 ` Felipe Balbi [this message]
2019-07-16 7:20 ` [RFC PATCH 4/5] PTP: Add flag for non-periodic output Felipe Balbi
2019-07-16 16:39 ` Richard Cochran
2019-07-17 6:49 ` Felipe Balbi
2019-07-17 17:36 ` Richard Cochran
2019-07-18 8:59 ` Felipe Balbi
2019-07-18 16:41 ` Richard Cochran
2019-08-13 7:53 ` Felipe Balbi
2019-08-13 17:48 ` Richard Cochran
2019-08-13 18:06 ` Richard Cochran
2019-08-14 7:05 ` Felipe Balbi
2019-07-16 7:20 ` [RFC PATCH 5/5] PTP: Add support for Intel PMC Timed GPIO Controller Felipe Balbi
2019-07-16 19:14 ` Shannon Nelson
2019-07-17 6:51 ` Felipe Balbi
2019-07-16 16:41 ` [RFC PATCH 0/5] PTP: add support for Intel's TGPIO controller Richard Cochran
2019-07-17 6:52 ` Felipe Balbi
2019-07-17 17:39 ` Richard Cochran
2019-07-18 8:58 ` Felipe Balbi
2019-07-18 19:50 ` Andrew Lunn
2019-07-19 7:35 ` Felipe Balbi
2019-07-19 13:20 ` Andrew Lunn
2019-08-13 7:50 ` Felipe Balbi
2019-08-13 17:49 ` Richard Cochran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190716072038.8408-4-felipe.balbi@linux.intel.com \
--to=felipe.balbi@linux.intel.com \
--cc=bp@alien8.de \
--cc=christopher.s.hall@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).