This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / kernel / ksysfs.c
1 /*
2  * kernel/ksysfs.c - sysfs attributes in /sys/kernel, which
3  *                   are not related to any other subsystem
4  *
5  * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
6  * 
7  * This file is release under the GPLv2
8  *
9  */
10
11 #include <linux/config.h>
12 #include <linux/kobject.h>
13 #include <linux/string.h>
14 #include <linux/sysfs.h>
15 #include <linux/module.h>
16 #include <linux/init.h>
17
18 #define KERNEL_ATTR_RO(_name) \
19 static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
20
21 #define KERNEL_ATTR_RW(_name) \
22 static struct subsys_attribute _name##_attr = \
23         __ATTR(_name, 0644, _name##_show, _name##_store)
24
25 #ifdef CONFIG_HOTPLUG
26 static ssize_t hotplug_seqnum_show(struct subsystem *subsys, char *page)
27 {
28         return sprintf(page, "%llu\n", (unsigned long long)hotplug_seqnum);
29 }
30 KERNEL_ATTR_RO(hotplug_seqnum);
31 #endif
32
33 static decl_subsys(kernel, NULL, NULL);
34
35 static struct attribute * kernel_attrs[] = {
36 #ifdef CONFIG_HOTPLUG
37         &hotplug_seqnum_attr.attr,
38 #endif
39         NULL
40 };
41
42 static struct attribute_group kernel_attr_group = {
43         .attrs = kernel_attrs,
44 };
45
46 static int __init ksysfs_init(void)
47 {
48         int error = subsystem_register(&kernel_subsys);
49         if (!error)
50                 error = sysfs_create_group(&kernel_subsys.kset.kobj,
51                                            &kernel_attr_group);
52
53         return error;
54 }
55
56 core_initcall(ksysfs_init);