summaryrefslogtreecommitdiff
path: root/drivers/xen
diff options
context:
space:
mode:
authorStefano Stabellini <sstabellini@kernel.org>2017-07-05 13:08:48 -0700
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>2017-08-31 09:45:55 -0400
commit9be07334f99e1f9e0b244d73528bc3afce126735 (patch)
treef19c721f4fe8fea6142e14e61bcaad20bc5622bf /drivers/xen
parent72e59c30df449bc7fe601716e60c824b4ffe606d (diff)
downloadlwn-9be07334f99e1f9e0b244d73528bc3afce126735.tar.gz
lwn-9be07334f99e1f9e0b244d73528bc3afce126735.zip
xen/pvcalls: initialize the module and register the xenbus backend
Keep a list of connected frontends. Use a semaphore to protect list accesses. Signed-off-by: Stefano Stabellini <stefano@aporeto.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Reviewed-by: Juergen Gross <jgross@suse.com> CC: boris.ostrovsky@oracle.com CC: jgross@suse.com Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/pvcalls-back.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c
index f3d0daad3da6..9044cf21b31c 100644
--- a/drivers/xen/pvcalls-back.c
+++ b/drivers/xen/pvcalls-back.c
@@ -25,6 +25,11 @@
#include <xen/xenbus.h>
#include <xen/interface/io/pvcalls.h>
+struct pvcalls_back_global {
+ struct list_head frontends;
+ struct semaphore frontends_lock;
+} pvcalls_back_global;
+
static int pvcalls_back_probe(struct xenbus_device *dev,
const struct xenbus_device_id *id)
{
@@ -59,3 +64,20 @@ static struct xenbus_driver pvcalls_back_driver = {
.uevent = pvcalls_back_uevent,
.otherend_changed = pvcalls_back_changed,
};
+
+static int __init pvcalls_back_init(void)
+{
+ int ret;
+
+ if (!xen_domain())
+ return -ENODEV;
+
+ ret = xenbus_register_backend(&pvcalls_back_driver);
+ if (ret < 0)
+ return ret;
+
+ sema_init(&pvcalls_back_global.frontends_lock, 1);
+ INIT_LIST_HEAD(&pvcalls_back_global.frontends);
+ return 0;
+}
+module_init(pvcalls_back_init);