public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Prarit Bhargava <prarit@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Prarit Bhargava <prarit@redhat.com>,
	John Stultz <johnstul@us.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH] ntp, add debugfs entries for time_status and time_state
Date: Thu,  4 Oct 2012 09:48:41 -0400	[thread overview]
Message-ID: <1349358521-4386-1-git-send-email-prarit@redhat.com> (raw)

Add debugfs entries for ntp time_status and time_state.  These are useful
for debugging ntp issues.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: John Stultz <johnstul@us.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/time/ntp.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 24174b4..e1ba393 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -15,6 +15,7 @@
 #include <linux/time.h>
 #include <linux/mm.h>
 #include <linux/module.h>
+#include <linux/debugfs.h>
 
 #include "tick-internal.h"
 
@@ -965,3 +966,42 @@ void __init ntp_init(void)
 {
 	ntp_clear();
 }
+
+static int time_status_get(void *data, u64 *val)
+{
+	*val = time_status;
+	return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(time_status_fops, time_status_get, NULL, "0x%0llx\n");
+
+static int time_state_get(void *data, u64 *val)
+{
+	*val = time_state;
+	return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(time_state_fops, time_state_get, NULL, "0x%llx\n");
+
+static int __init ntp_debugfs_init(void)
+{
+	struct dentry *ntp_dentry, *time_status_dentry, *time_state_dentry;
+
+	ntp_dentry = debugfs_create_dir("ntp", NULL);
+	if (!ntp_dentry)
+		return -ENOMEM;
+
+	time_status_dentry = debugfs_create_file("time_status", 0444,
+						 ntp_dentry, NULL,
+						 &time_status_fops);
+	if (!time_status_dentry)
+		return -ENOMEM;
+
+	time_state_dentry = debugfs_create_file("time_state", 0444,
+						ntp_dentry, NULL,
+						&time_state_fops);
+	if (!time_state_dentry)
+		return -ENOMEM;
+
+	return 0;
+}
+/* debugfs init is core_initcall */
+postcore_initcall(ntp_debugfs_init);
-- 
1.7.9.3


             reply	other threads:[~2012-10-04 13:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-04 13:48 Prarit Bhargava [this message]
2012-10-09  1:47 ` [PATCH] ntp, add debugfs entries for time_status and time_state John Stultz
2012-10-09 11:05   ` Prarit Bhargava

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=1349358521-4386-1-git-send-email-prarit@redhat.com \
    --to=prarit@redhat.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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