From owner-svn-src-head@FreeBSD.ORG Tue Sep 30 17:31:05 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 76708B55; Tue, 30 Sep 2014 17:31:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6243DE2C; Tue, 30 Sep 2014 17:31:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8UHV5lR015777; Tue, 30 Sep 2014 17:31:05 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8UHV4oQ015773; Tue, 30 Sep 2014 17:31:04 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201409301731.s8UHV4oQ015773@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: Roger Pau Monné Date: Tue, 30 Sep 2014 17:31:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272318 - in head/sys: dev/xen/xenstore xen/xenstore X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Sep 2014 17:31:05 -0000 Author: royger Date: Tue Sep 30 17:31:04 2014 New Revision: 272318 URL: http://svnweb.freebsd.org/changeset/base/272318 Log: xen: convert the xenstore user-space char device to a newbus device Convert the xenstore user-space device (/dev/xen/xenstore) to a device using the newbus interface. This allows us to make the device initialization dependant on the initialization of xenstore itself in the kernel. Sponsored by: Citrix Systems R&D dev/xen/xenstore/xenstore.c: - Convert to a newbus device, this removes the xs_dev_init function. xen/xenstore/xenstore_internal.h: - Remove xs_dev_init prototype. dev/xen/xenstore/xenstore.c: - Don't call xs_dev_init anymore, the device will attach itself when xenstore is started. Modified: head/sys/dev/xen/xenstore/xenstore.c head/sys/dev/xen/xenstore/xenstore_dev.c head/sys/xen/xenstore/xenstore_internal.h Modified: head/sys/dev/xen/xenstore/xenstore.c ============================================================================== --- head/sys/dev/xen/xenstore/xenstore.c Tue Sep 30 17:27:56 2014 (r272317) +++ head/sys/dev/xen/xenstore/xenstore.c Tue Sep 30 17:31:04 2014 (r272318) @@ -1130,7 +1130,6 @@ xs_probe(device_t dev) static void xs_attach_deferred(void *arg) { - xs_dev_init(); bus_generic_probe(xs.xs_dev); bus_generic_attach(xs.xs_dev); Modified: head/sys/dev/xen/xenstore/xenstore_dev.c ============================================================================== --- head/sys/dev/xen/xenstore/xenstore_dev.c Tue Sep 30 17:27:56 2014 (r272317) +++ head/sys/dev/xen/xenstore/xenstore_dev.c Tue Sep 30 17:31:04 2014 (r272318) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -216,9 +217,71 @@ static struct cdevsw xs_dev_cdevsw = { .d_name = "xs_dev", }; -void -xs_dev_init() +/*------------------ Private Device Attachment Functions --------------------*/ +/** + * \brief Identify instances of this device type in the system. + * + * \param driver The driver performing this identify action. + * \param parent The NewBus parent device for any devices this method adds. + */ +static void +xs_dev_identify(driver_t *driver __unused, device_t parent) +{ + /* + * A single device instance for our driver is always present + * in a system operating under Xen. + */ + BUS_ADD_CHILD(parent, 0, driver->name, 0); +} + +/** + * \brief Probe for the existance of the Xenstore device + * + * \param dev NewBus device_t for this instance. + * + * \return Always returns 0 indicating success. + */ +static int +xs_dev_probe(device_t dev) +{ + + device_set_desc(dev, "Xenstore user-space device"); + return (0); +} + +/** + * \brief Attach the Xenstore device. + * + * \param dev NewBus device_t for this instance. + * + * \return On success, 0. Otherwise an errno value indicating the + * type of failure. + */ +static int +xs_dev_attach(device_t dev) { - make_dev(&xs_dev_cdevsw, 0, UID_ROOT, GID_WHEEL, 0400, + struct cdev *xs_cdev; + + xs_cdev = make_dev(&xs_dev_cdevsw, 0, UID_ROOT, GID_WHEEL, 0400, "xen/xenstore"); + if (xs_cdev == NULL) + return (EINVAL); + + return (0); } + +/*-------------------- Private Device Attachment Data -----------------------*/ +static device_method_t xs_dev_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, xs_dev_identify), + DEVMETHOD(device_probe, xs_dev_probe), + DEVMETHOD(device_attach, xs_dev_attach), + + DEVMETHOD_END +}; + +DEFINE_CLASS_0(xs_dev, xs_dev_driver, xs_dev_methods, 0); +devclass_t xs_dev_devclass; + +DRIVER_MODULE(xs_dev, xenstore, xs_dev_driver, xs_dev_devclass, + NULL, NULL); Modified: head/sys/xen/xenstore/xenstore_internal.h ============================================================================== --- head/sys/xen/xenstore/xenstore_internal.h Tue Sep 30 17:27:56 2014 (r272317) +++ head/sys/xen/xenstore/xenstore_internal.h Tue Sep 30 17:31:04 2014 (r272318) @@ -32,8 +32,5 @@ * $FreeBSD$ */ -/* Initialize support for userspace access to the XenStore. */ -void xs_dev_init(void); - /* Used by the XenStore character device to borrow kernel's store connection. */ int xs_dev_request_and_reply(struct xsd_sockmsg *msg, void **result);