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/kernel.h>
11 #include <linux/module.h>
12 #include <linux/kobject.h>
13 #include <xen/hypervisor_sysfs.h>
15 decl_subsys(hypervisor, NULL, NULL);
17 static ssize_t hyp_sysfs_show(struct kobject *kobj,
18 struct attribute *attr,
21 struct hyp_sysfs_attr *hyp_attr;
22 hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
24 return hyp_attr->show(hyp_attr, buffer);
28 static ssize_t hyp_sysfs_store(struct kobject *kobj,
29 struct attribute *attr,
33 struct hyp_sysfs_attr *hyp_attr;
34 hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
36 return hyp_attr->store(hyp_attr, buffer, len);
40 struct sysfs_ops hyp_sysfs_ops = {
41 .show = hyp_sysfs_show,
42 .store = hyp_sysfs_store,
45 static struct kobj_type hyp_sysfs_kobj_type = {
46 .sysfs_ops = &hyp_sysfs_ops,
49 static int __init hypervisor_subsys_init(void)
51 if (!is_running_on_xen())
54 hypervisor_subsys.kset.kobj.ktype = &hyp_sysfs_kobj_type;
55 return subsystem_register(&hypervisor_subsys);
58 device_initcall(hypervisor_subsys_init);
59 EXPORT_SYMBOL_GPL(hypervisor_subsys);