lkml.org 
[lkml]   [2014]   [Feb]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/6] Add sysfs RO interface to tick_do_timer_cpu
Date
Most of this is 'extras' needed in order to get sysfs working.

CC: Thomas Gleixner <tglx@linutronix.de>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: John Stultz <john.stultz@linaro.org>

Signed-off-by: Henrik Austad <haustad@cisco.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[] = {
+ &current_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


\
 
 \ /
  Last update: 2014-02-25 14:21    [W:0.086 / U:5.572 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site