Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / drivers / xen / core / hypervisor_sysfs.c
1 /*
2  *  copyright (c) 2006 IBM Corporation
3  *  Authored by: Mike D. Day <ncmike@us.ibm.com>
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License version 2 as
7  *  published by the Free Software Foundation.
8  */
9
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/kobject.h>
13 #include <xen/hypervisor_sysfs.h>
14
15 decl_subsys(hypervisor, NULL, NULL);
16
17 static ssize_t hyp_sysfs_show(struct kobject *kobj,
18                               struct attribute *attr,
19                               char *buffer)
20 {
21         struct hyp_sysfs_attr *hyp_attr;
22         hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
23         if (hyp_attr->show)
24                 return hyp_attr->show(hyp_attr, buffer);
25         return 0;
26 }
27
28 static ssize_t hyp_sysfs_store(struct kobject *kobj,
29                                struct attribute *attr,
30                                const char *buffer,
31                                size_t len)
32 {
33         struct hyp_sysfs_attr *hyp_attr;
34         hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
35         if (hyp_attr->store)
36                 return hyp_attr->store(hyp_attr, buffer, len);
37         return 0;
38 }
39
40 struct sysfs_ops hyp_sysfs_ops = {
41         .show = hyp_sysfs_show,
42         .store = hyp_sysfs_store,
43 };
44
45 static struct kobj_type hyp_sysfs_kobj_type = {
46         .sysfs_ops = &hyp_sysfs_ops,
47 };
48
49 static int __init hypervisor_subsys_init(void)
50 {
51         if (!is_running_on_xen())
52                 return -ENODEV;
53
54         hypervisor_subsys.kset.kobj.ktype = &hyp_sysfs_kobj_type;
55         return subsystem_register(&hypervisor_subsys);
56 }
57
58 device_initcall(hypervisor_subsys_init);
59 EXPORT_SYMBOL_GPL(hypervisor_subsys);