Most of this is 'extras' needed in order to get sysfs working. CC: Thomas Gleixner <[email protected]> CC: Peter Zijlstra <[email protected]> CC: Frederic Weisbecker <[email protected]> CC: John Stultz <[email protected]>
Signed-off-by: Henrik Austad <[email protected]> --- 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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

