This commit was manufactured by cvs2svn to create branch 'vserver'.
[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/config.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/kobject.h>
14 #include <xen/hypervisor_sysfs.h>
15
16 decl_subsys(hypervisor, NULL, NULL);
17
18 static ssize_t hyp_sysfs_show(struct kobject *kobj,
19                               struct attribute *attr,
20                               char *buffer)
21 {
22         struct hyp_sysfs_attr *hyp_attr;
23         hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
24         if (hyp_attr->show)
25                 return hyp_attr->show(hyp_attr, buffer);
26         return 0;
27 }
28
29 static ssize_t hyp_sysfs_store(struct kobject *kobj,
30                                struct attribute *attr,
31                                const char *buffer,
32                                size_t len)
33 {
34         struct hyp_sysfs_attr *hyp_attr;
35         hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
36         if (hyp_attr->store)
37                 return hyp_attr->store(hyp_attr, buffer, len);
38         return 0;
39 }
40
41 struct sysfs_ops hyp_sysfs_ops = {
42         .show = hyp_sysfs_show,
43         .store = hyp_sysfs_store,
44 };
45
46 static struct kobj_type hyp_sysfs_kobj_type = {
47         .sysfs_ops = &hyp_sysfs_ops,
48 };
49
50 static int __init hypervisor_subsys_init(void)
51 {
52         if (!is_running_on_xen())
53                 return -ENODEV;
54
55         hypervisor_subsys.kset.kobj.ktype = &hyp_sysfs_kobj_type;
56         return subsystem_register(&hypervisor_subsys);
57 }
58
59 device_initcall(hypervisor_subsys_init);
60 EXPORT_SYMBOL_GPL(hypervisor_subsys);