Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751508AbdFBTf5 (ORCPT ); Fri, 2 Jun 2017 15:35:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:55982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751231AbdFBTb6 (ORCPT ); Fri, 2 Jun 2017 15:31:58 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5A8C23A26 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=sstabellini@kernel.org From: Stefano Stabellini To: xen-devel@lists.xen.org Cc: linux-kernel@vger.kernel.org, sstabellini@kernel.org, jgross@suse.com, boris.ostrovsky@oracle.com, Stefano Stabellini Subject: [PATCH v3 03/18] xen/pvcalls: initialize the module and register the xenbus backend Date: Fri, 2 Jun 2017 12:31:40 -0700 Message-Id: <1496431915-20774-3-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1496431915-20774-1-git-send-email-sstabellini@kernel.org> References: <1496431915-20774-1-git-send-email-sstabellini@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1326 Lines: 50 Keep a list of connected frontends. Use a semaphore to protect list accesses. Signed-off-by: Stefano Stabellini Reviewed-by: Boris Ostrovsky CC: boris.ostrovsky@oracle.com CC: jgross@suse.com --- drivers/xen/pvcalls-back.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c index f3d0daa..9044cf2 100644 --- a/drivers/xen/pvcalls-back.c +++ b/drivers/xen/pvcalls-back.c @@ -25,6 +25,11 @@ #include #include +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 int pvcalls_back_uevent(struct xenbus_device *xdev, .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); -- 1.9.1