[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1393331641-14016-3-git-send-email-henrik@austad.us>
Date: Tue, 25 Feb 2014 13:33:57 +0100
From: Henrik Austad <henrik@...tad.us>
To: LKML <linux-kernel@...r.kernel.org>,
Thomas Gleixner <tglx@...uxtronix.de>
Cc: Henrik Austad <henrik@...tad.us>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Frederic Weisbecker <fweisbec@...il.com>,
John Stultz <john.stultz@...aro.org>,
Henrik Austad <haustad@...co.com>
Subject: [PATCH 2/6] Add sysfs RO interface to tick_do_timer_cpu
Most of this is 'extras' needed in order to get sysfs working.
CC: Thomas Gleixner <tglx@...utronix.de>
CC: Peter Zijlstra <peterz@...radead.org>
CC: Frederic Weisbecker <fweisbec@...il.com>
CC: John Stultz <john.stultz@...aro.org>
Signed-off-by: Henrik Austad <haustad@...co.com>
---
kernel/time/timekeeping.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 0aa4ce8..f7c6b1f 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -22,11 +22,54 @@
#include <linux/tick.h>
#include <linux/stop_machine.h>
#include <linux/pvclock_gtod.h>
+#include <linux/kobject.h>
+#include <linux/sysfs.h>
#include "tick-internal.h"
#include "ntp_internal.h"
#include "timekeeping_internal.h"
+/*
+ * sysfs interface to timer-cpu
+ */
+static ssize_t current_cpu_show(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "%d\n", tick_expose_cpu());
+}
+
+static struct kobj_attribute current_cpu_attribute =
+ __ATTR_RO(current_cpu);
+
+static struct attribute *timekeeping_attrs[] = {
+ ¤t_cpu_attribute.attr,
+ NULL,
+};
+static struct attribute_group timekeeping_ag = {
+ .attrs = timekeeping_attrs,
+};
+static struct kobject *timekeeping_kobj;
+
+static __init int timekeeping_sysfs_init(void)
+{
+ int ret = 0;
+
+ timekeeping_kobj = kobject_create_and_add("timekeeping", kernel_kobj);
+ if (!timekeeping_kobj)
+ return -ENOMEM;
+
+ ret = sysfs_create_group(timekeeping_kobj, &timekeeping_ag);
+ if (ret) {
+ pr_err("timekeeping: could not create attribute-group %d\n", ret);
+ kobject_put(timekeeping_kobj);
+ }
+ return ret;
+}
+
+/* need to make sure that kobj and sysfs is initialized before running this */
+late_initcall(timekeeping_sysfs_init);
+
#define TK_CLEAR_NTP (1 << 0)
#define TK_MIRROR (1 << 1)
#define TK_CLOCK_WAS_SET (1 << 2)
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists