aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
authorBastian Blank <waldi@debian.org>2011-12-10 13:29:47 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-12-16 13:29:39 -0500
commit2fb3683e7b164ee2b324039f7c9d90fe5b1a259b (patch)
tree7ac2e97b48e0940340c37aae4d08a6b67f1e4fd5 /drivers/xen
parentd8414d3c157dc1f83e73c17447ba41fe5afa9d3d (diff)
xen: Add xenbus device driver
Access to xenbus is currently handled via xenfs. This adds a device driver for xenbus and makes xenfs use this code. Signed-off-by: Bastian Blank <waldi@debian.org> Acked-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/xenbus/Makefile1
-rw-r--r--drivers/xen/xenbus/xenbus_comms.h4
-rw-r--r--drivers/xen/xenbus/xenbus_dev_frontend.c (renamed from drivers/xen/xenfs/xenbus.c)37
-rw-r--r--drivers/xen/xenfs/Makefile2
-rw-r--r--drivers/xen/xenfs/super.c3
-rw-r--r--drivers/xen/xenfs/xenfs.h1
6 files changed, 42 insertions, 6 deletions
diff --git a/drivers/xen/xenbus/Makefile b/drivers/xen/xenbus/Makefile
index 8dca685358b4..a2ea363b9f34 100644
--- a/drivers/xen/xenbus/Makefile
+++ b/drivers/xen/xenbus/Makefile
@@ -1,4 +1,5 @@
1obj-y += xenbus.o 1obj-y += xenbus.o
2obj-y += xenbus_dev_frontend.o
2 3
3xenbus-objs = 4xenbus-objs =
4xenbus-objs += xenbus_client.o 5xenbus-objs += xenbus_client.o
diff --git a/drivers/xen/xenbus/xenbus_comms.h b/drivers/xen/xenbus/xenbus_comms.h
index c21db7513736..6e42800fa499 100644
--- a/drivers/xen/xenbus/xenbus_comms.h
+++ b/drivers/xen/xenbus/xenbus_comms.h
@@ -31,6 +31,8 @@
31#ifndef _XENBUS_COMMS_H 31#ifndef _XENBUS_COMMS_H
32#define _XENBUS_COMMS_H 32#define _XENBUS_COMMS_H
33 33
34#include <linux/fs.h>
35
34int xs_init(void); 36int xs_init(void);
35int xb_init_comms(void); 37int xb_init_comms(void);
36 38
@@ -43,4 +45,6 @@ int xs_input_avail(void);
43extern struct xenstore_domain_interface *xen_store_interface; 45extern struct xenstore_domain_interface *xen_store_interface;
44extern int xen_store_evtchn; 46extern int xen_store_evtchn;
45 47
48extern const struct file_operations xen_xenbus_fops;
49
46#endif /* _XENBUS_COMMS_H */ 50#endif /* _XENBUS_COMMS_H */
diff --git a/drivers/xen/xenfs/xenbus.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
index bbd000f88af7..fb30cffe0338 100644
--- a/drivers/xen/xenfs/xenbus.c
+++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
@@ -52,13 +52,16 @@
52#include <linux/namei.h> 52#include <linux/namei.h>
53#include <linux/string.h> 53#include <linux/string.h>
54#include <linux/slab.h> 54#include <linux/slab.h>
55#include <linux/miscdevice.h>
56#include <linux/module.h>
55 57
56#include "xenfs.h" 58#include "xenbus_comms.h"
57#include "../xenbus/xenbus_comms.h"
58 59
59#include <xen/xenbus.h> 60#include <xen/xenbus.h>
60#include <asm/xen/hypervisor.h> 61#include <asm/xen/hypervisor.h>
61 62
63MODULE_LICENSE("GPL");
64
62/* 65/*
63 * An element of a list of outstanding transactions, for which we're 66 * An element of a list of outstanding transactions, for which we're
64 * still waiting a reply. 67 * still waiting a reply.
@@ -583,7 +586,7 @@ static unsigned int xenbus_file_poll(struct file *file, poll_table *wait)
583 return 0; 586 return 0;
584} 587}
585 588
586const struct file_operations xenbus_file_ops = { 589const struct file_operations xen_xenbus_fops = {
587 .read = xenbus_file_read, 590 .read = xenbus_file_read,
588 .write = xenbus_file_write, 591 .write = xenbus_file_write,
589 .open = xenbus_file_open, 592 .open = xenbus_file_open,
@@ -591,3 +594,31 @@ const struct file_operations xenbus_file_ops = {
591 .poll = xenbus_file_poll, 594 .poll = xenbus_file_poll,
592 .llseek = no_llseek, 595 .llseek = no_llseek,
593}; 596};
597EXPORT_SYMBOL_GPL(xen_xenbus_fops);
598
599static struct miscdevice xenbus_dev = {
600 .minor = MISC_DYNAMIC_MINOR,
601 .name = "xen/xenbus",
602 .fops = &xen_xenbus_fops,
603};
604
605static int __init xenbus_init(void)
606{
607 int err;
608
609 if (!xen_domain())
610 return -ENODEV;
611
612 err = misc_register(&xenbus_dev);
613 if (err)
614 printk(KERN_ERR "Could not register xenbus device\n");
615 return err;
616}
617
618static void __exit xenbus_exit(void)
619{
620 misc_deregister(&xenbus_dev);
621}
622
623module_init(xenbus_init);
624module_exit(xenbus_exit);
diff --git a/drivers/xen/xenfs/Makefile b/drivers/xen/xenfs/Makefile
index 5d45ff13cc01..b019865fcc56 100644
--- a/drivers/xen/xenfs/Makefile
+++ b/drivers/xen/xenfs/Makefile
@@ -1,4 +1,4 @@
1obj-$(CONFIG_XENFS) += xenfs.o 1obj-$(CONFIG_XENFS) += xenfs.o
2 2
3xenfs-y = super.o xenbus.o 3xenfs-y = super.o
4xenfs-$(CONFIG_XEN_DOM0) += xenstored.o 4xenfs-$(CONFIG_XEN_DOM0) += xenstored.o
diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c
index a55fbf9a1519..a84b53c01436 100644
--- a/drivers/xen/xenfs/super.c
+++ b/drivers/xen/xenfs/super.c
@@ -17,6 +17,7 @@
17 17
18#include "xenfs.h" 18#include "xenfs.h"
19#include "../privcmd.h" 19#include "../privcmd.h"
20#include "../xenbus/xenbus_comms.h"
20 21
21#include <asm/xen/hypervisor.h> 22#include <asm/xen/hypervisor.h>
22 23
@@ -83,7 +84,7 @@ static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
83{ 84{
84 static struct tree_descr xenfs_files[] = { 85 static struct tree_descr xenfs_files[] = {
85 [1] = {}, 86 [1] = {},
86 { "xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR }, 87 { "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR },
87 { "capabilities", &capabilities_file_ops, S_IRUGO }, 88 { "capabilities", &capabilities_file_ops, S_IRUGO },
88 { "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR }, 89 { "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR },
89 {""}, 90 {""},
diff --git a/drivers/xen/xenfs/xenfs.h b/drivers/xen/xenfs/xenfs.h
index 5056306e7aa8..6b80c7779c02 100644
--- a/drivers/xen/xenfs/xenfs.h
+++ b/drivers/xen/xenfs/xenfs.h
@@ -1,7 +1,6 @@
1#ifndef _XENFS_XENBUS_H 1#ifndef _XENFS_XENBUS_H
2#define _XENFS_XENBUS_H 2#define _XENFS_XENBUS_H
3 3
4extern const struct file_operations xenbus_file_ops;
5extern const struct file_operations xsd_kva_file_ops; 4extern const struct file_operations xsd_kva_file_ops;
6extern const struct file_operations xsd_port_file_ops; 5extern const struct file_operations xsd_port_file_ops;
7 6