2 * copyright (c) 2006 IBM Corporation
3 * Authored by: Mike D. Day <ncmike@us.ibm.com>
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.
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>
16 decl_subsys(hypervisor, NULL, NULL);
18 static ssize_t hyp_sysfs_show(struct kobject *kobj,
19 struct attribute *attr,
22 struct hyp_sysfs_attr *hyp_attr;
23 hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
25 return hyp_attr->show(hyp_attr, buffer);
29 static ssize_t hyp_sysfs_store(struct kobject *kobj,
30 struct attribute *attr,
34 struct hyp_sysfs_attr *hyp_attr;
35 hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
37 return hyp_attr->store(hyp_attr, buffer, len);
41 struct sysfs_ops hyp_sysfs_ops = {
42 .show = hyp_sysfs_show,
43 .store = hyp_sysfs_store,
46 static struct kobj_type hyp_sysfs_kobj_type = {
47 .sysfs_ops = &hyp_sysfs_ops,
50 static int __init hypervisor_subsys_init(void)
52 if (!is_running_on_xen())
55 hypervisor_subsys.kset.kobj.ktype = &hyp_sysfs_kobj_type;
56 return subsystem_register(&hypervisor_subsys);
59 device_initcall(hypervisor_subsys_init);
60 EXPORT_SYMBOL_GPL(hypervisor_subsys);