All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@suse.de>
To: Xen devel list <xen-devel@lists.xensource.com>
Subject: [PATCH] cleanup "struct xenbus_driver"
Date: Tue, 11 Jul 2006 09:32:58 +0200	[thread overview]
Message-ID: <44B3542A.20301@suse.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 382 bytes --]

  Hi,

This patch is a cleanup for "struct xenbus_driver" and
the xenbus code.

"struct xenbus_driver" has alot of elements duplicated
with "struct device_driver".  This patch removes them
all and does the related code changes.

patch is against changeset 10650 (unstable tree).

please apply,

  Gerd

-- 
Gerd Hoffmann <kraxel@suse.de>
http://www.suse.de/~kraxel/julika-dora.jpeg

[-- Attachment #2: xenbus-cleanups-submit.diff --]
[-- Type: text/x-patch, Size: 22839 bytes --]

This patch is a cleanup for "struct xenbus_driver" and
the xenbus code.

"struct xenbus_driver" has alot of elements duplicated
with "struct device_driver".  This patch removes them
all and does the related code changes.

Signed-off-by: Gerd Hoffmann <kraxel@suse.de>
-- 
diff -r a1c2cede77c7 linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
--- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Mon Jul 10 14:01:49 2006
+++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Tue Jul 11 09:21:36 2006
@@ -367,11 +367,11 @@
 	.max_tx_size = PAGE_SIZE * TPMIF_TX_RING_SIZE,
 };
 
-static int tpmfront_probe(struct xenbus_device *dev,
-                          const struct xenbus_device_id *id)
+static int tpmfront_probe(struct device *device)
 {
 	int err;
 	int handle;
+	struct xenbus_device *dev = to_xenbus_device(device);
 	struct tpm_private *tp = tpm_private_get();
 
 	if (!tp)
@@ -404,17 +404,17 @@
 }
 
 
-static int tpmfront_remove(struct xenbus_device *dev)
-{
-	struct tpm_private *tp = tpm_private_from_dev(&dev->dev);
+static int tpmfront_remove(struct device *device)
+{
+	struct tpm_private *tp = tpm_private_from_dev(device);
 	destroy_tpmring(tp);
-	cleanup_vtpm(&dev->dev);
+	cleanup_vtpm(device);
 	return 0;
 }
 
-static int tpmfront_suspend(struct xenbus_device *dev)
-{
-	struct tpm_private *tp = tpm_private_from_dev(&dev->dev);
+static int tpmfront_suspend(struct device *device, pm_message_t state)
+{
+	struct tpm_private *tp = tpm_private_from_dev(device);
 	u32 ctr;
 	/* lock, so no app can send */
 	mutex_lock(&suspend_lock);
@@ -428,7 +428,7 @@
 		 */
 		interruptible_sleep_on_timeout(&tp->wait_q, 100);
 	}
-	xenbus_switch_state(dev, XenbusStateClosing);
+	xenbus_switch_state(to_xenbus_device(device), XenbusStateClosing);
 
 	if (atomic_read(&tp->tx_busy)) {
 		/*
@@ -441,11 +441,11 @@
 	return 0;
 }
 
-static int tpmfront_resume(struct xenbus_device *dev)
-{
-	struct tpm_private *tp = tpm_private_from_dev(&dev->dev);
+static int tpmfront_resume(struct device *device)
+{
+	struct tpm_private *tp = tpm_private_from_dev(device);
 	destroy_tpmring(tp);
-	return talk_to_backend(dev, tp);
+	return talk_to_backend(to_xenbus_device(device), tp);
 }
 
 static int tpmif_connect(struct xenbus_device *dev,
@@ -478,14 +478,14 @@
 };
 
 static struct xenbus_driver tpmfront = {
-	.name = "vtpm",
-	.owner = THIS_MODULE,
 	.ids = tpmfront_ids,
-	.probe = tpmfront_probe,
-	.remove =  tpmfront_remove,
-	.resume = tpmfront_resume,
+	.driver.name    = "vtpm",
+	.driver.owner   = THIS_MODULE,
+	.driver.probe   = tpmfront_probe,
+	.driver.remove  = tpmfront_remove,
+	.driver.resume  = tpmfront_resume,
+	.driver.suspend = tpmfront_suspend,
 	.otherend_changed = backend_changed,
-	.suspend = tpmfront_suspend,
 };
 
 static void __init init_tpm_xenbus(void)
diff -r a1c2cede77c7 linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Mon Jul 10 14:01:49 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Tue Jul 11 09:21:36 2006
@@ -138,8 +138,9 @@
 	device_remove_file(&dev->dev, &dev_attr_physical_device);
 }
 
-static int blkback_remove(struct xenbus_device *dev)
-{
+static int blkback_remove(struct device *device)
+{
+	struct xenbus_device *dev = to_xenbus_device(device);
 	struct backend_info *be = dev->dev.driver_data;
 
 	DPRINTK("");
@@ -171,10 +172,10 @@
  * structures, and watch the store waiting for the hotplug scripts to tell us
  * the device's physical major and minor numbers.  Switch to InitWait.
  */
-static int blkback_probe(struct xenbus_device *dev,
-			 const struct xenbus_device_id *id)
-{
-	int err;
+static int blkback_probe(struct device *device)
+{
+	int err;
+	struct xenbus_device *dev = to_xenbus_device(device);
 	struct backend_info *be = kzalloc(sizeof(struct backend_info),
 					  GFP_KERNEL);
 	if (!be) {
@@ -183,7 +184,7 @@
 		return -ENOMEM;
 	}
 	be->dev = dev;
-	dev->dev.driver_data = be;
+	device->driver_data = be;
 
 	be->blkif = blkif_alloc(dev->otherend_id);
 	if (IS_ERR(be->blkif)) {
@@ -209,7 +210,7 @@
 
 fail:
 	DPRINTK("failed");
-	blkback_remove(dev);
+	blkback_remove(&dev->dev);
 	return err;
 }
 
@@ -445,11 +446,11 @@
 
 
 static struct xenbus_driver blkback = {
-	.name = "vbd",
-	.owner = THIS_MODULE,
 	.ids = blkback_ids,
-	.probe = blkback_probe,
-	.remove = blkback_remove,
+	.driver.name   = "vbd",
+	.driver.owner  = THIS_MODULE,
+	.driver.probe  = blkback_probe,
+	.driver.remove = blkback_remove,
 	.otherend_changed = frontend_changed
 };
 
diff -r a1c2cede77c7 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Jul 10 14:01:49 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Tue Jul 11 09:21:36 2006
@@ -57,7 +57,7 @@
 
 static void connect(struct blkfront_info *);
 static void blkfront_closing(struct xenbus_device *);
-static int blkfront_remove(struct xenbus_device *);
+static int blkfront_remove(struct device *);
 static int talk_to_backend(struct xenbus_device *, struct blkfront_info *);
 static int setup_blkring(struct xenbus_device *, struct blkfront_info *);
 
@@ -76,11 +76,11 @@
  * inform the backend of the appropriate details for those.  Switch to
  * Initialised state.
  */
-static int blkfront_probe(struct xenbus_device *dev,
-			  const struct xenbus_device_id *id)
+static int blkfront_probe(struct device *device)
 {
 	int err, vdevice, i;
 	struct blkfront_info *info;
+	struct xenbus_device *dev = to_xenbus_device(device);
 
 	/* FIXME: Use dynamic device id if this is not set. */
 	err = xenbus_scanf(XBT_NIL, dev->nodename,
@@ -126,9 +126,10 @@
  * leave the device-layer structures intact so that this is transparent to the
  * rest of the kernel.
  */
-static int blkfront_resume(struct xenbus_device *dev)
-{
-	struct blkfront_info *info = dev->dev.driver_data;
+static int blkfront_resume(struct device *device)
+{
+	struct xenbus_device *dev = to_xenbus_device(device);
+	struct blkfront_info *info = device->driver_data;
 	int err;
 
 	DPRINTK("blkfront_resume: %s\n", dev->nodename);
@@ -363,11 +364,11 @@
 }
 
 
-static int blkfront_remove(struct xenbus_device *dev)
-{
-	struct blkfront_info *info = dev->dev.driver_data;
-
-	DPRINTK("blkfront_remove: %s removed\n", dev->nodename);
+static int blkfront_remove(struct device *device)
+{
+	struct blkfront_info *info = device->driver_data;
+
+	DPRINTK("blkfront_remove: %s removed\n", to_xenbus_device(device)->nodename);
 
 	blkif_free(info, 0);
 
@@ -812,12 +813,12 @@
 
 
 static struct xenbus_driver blkfront = {
-	.name = "vbd",
-	.owner = THIS_MODULE,
 	.ids = blkfront_ids,
-	.probe = blkfront_probe,
-	.remove = blkfront_remove,
-	.resume = blkfront_resume,
+	.driver.name      = "vbd",
+	.driver.owner     = THIS_MODULE,
+	.driver.probe     = blkfront_probe,
+	.driver.remove    = blkfront_remove,
+	.driver.resume    = blkfront_resume,
 	.otherend_changed = backend_changed,
 };
 
diff -r a1c2cede77c7 linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Mon Jul 10 14:01:49 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Tue Jul 11 09:21:36 2006
@@ -42,9 +42,10 @@
 static void backend_changed(struct xenbus_watch *, const char **,
 			    unsigned int);
 
-static int netback_remove(struct xenbus_device *dev)
-{
-	struct backend_info *be = dev->dev.driver_data;
+static int netback_remove(struct device *device)
+{
+	struct xenbus_device *dev = to_xenbus_device(device);
+	struct backend_info *be = device->driver_data;
 
 	if (be->backend_watch.node) {
 		unregister_xenbus_watch(&be->backend_watch);
@@ -66,12 +67,12 @@
  * structures, and watch the store waiting for the hotplug scripts to tell us
  * the device's handle.  Switch to InitWait.
  */
-static int netback_probe(struct xenbus_device *dev,
-			 const struct xenbus_device_id *id)
+static int netback_probe(struct device *device)
 {
 	const char *message;
 	struct xenbus_transaction xbt;
 	int err;
+	struct xenbus_device *dev = to_xenbus_device(device);
 	struct backend_info *be = kzalloc(sizeof(struct backend_info),
 					  GFP_KERNEL);
 	if (!be) {
@@ -81,7 +82,7 @@
 	}
 
 	be->dev = dev;
-	dev->dev.driver_data = be;
+	device->driver_data = be;
 
 	err = xenbus_watch_path2(dev, dev->nodename, "handle",
 				 &be->backend_watch, backend_changed);
@@ -130,7 +131,7 @@
 	xenbus_dev_fatal(dev, err, "%s", message);
 fail:
 	DPRINTK("failed");
-	netback_remove(dev);
+	netback_remove(device);
 	return err;
 }
 
@@ -389,11 +390,11 @@
 
 
 static struct xenbus_driver netback = {
-	.name = "vif",
-	.owner = THIS_MODULE,
 	.ids = netback_ids,
-	.probe = netback_probe,
-	.remove = netback_remove,
+	.driver.name   = "vif",
+	.driver.owner  = THIS_MODULE,
+	.driver.probe  = netback_probe,
+	.driver.remove = netback_remove,
 	.uevent = netback_uevent,
 	.otherend_changed = frontend_changed,
 };
diff -r a1c2cede77c7 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Mon Jul 10 14:01:49 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Jul 11 09:21:36 2006
@@ -183,13 +183,13 @@
  * inform the backend of the appropriate details for those.  Switch to
  * Connected state.
  */
-static int __devinit netfront_probe(struct xenbus_device *dev,
-				    const struct xenbus_device_id *id)
+static int __devinit netfront_probe(struct device *device)
 {
 	int err;
 	struct net_device *netdev;
 	struct netfront_info *info;
 	unsigned int handle;
+	struct xenbus_device *dev = to_xenbus_device(device);
 
 	err = xenbus_scanf(XBT_NIL, dev->nodename, "handle", "%u", &handle);
 	if (err != 1) {
@@ -226,9 +226,10 @@
  * leave the device-layer structures intact so that this is transparent to the
  * rest of the kernel.
  */
-static int netfront_resume(struct xenbus_device *dev)
-{
-	struct netfront_info *info = dev->dev.driver_data;
+static int netfront_resume(struct device *device)
+{
+	struct xenbus_device *dev = to_xenbus_device(device);
+	struct netfront_info *info = device->driver_data;
 
 	DPRINTK("%s\n", dev->nodename);
 
@@ -1491,11 +1492,11 @@
 }
 
 
-static int __devexit netfront_remove(struct xenbus_device *dev)
-{
-	struct netfront_info *info = dev->dev.driver_data;
-
-	DPRINTK("%s\n", dev->nodename);
+static int __devexit netfront_remove(struct device *device)
+{
+	struct netfront_info *info = device->driver_data;
+
+	DPRINTK("%s\n", to_xenbus_device(device)->nodename);
 
 	netif_disconnect_backend(info);
 	free_netdev(info->netdev);
@@ -1560,12 +1561,12 @@
 
 
 static struct xenbus_driver netfront = {
-	.name = "vif",
-	.owner = THIS_MODULE,
 	.ids = netfront_ids,
-	.probe = netfront_probe,
-	.remove = __devexit_p(netfront_remove),
-	.resume = netfront_resume,
+	.driver.name     = "vif",
+	.driver.owner    = THIS_MODULE,
+	.driver.probe    = netfront_probe,
+	.driver.remove   = __devexit_p(netfront_remove),
+	.driver.resume   = netfront_resume,
 	.otherend_changed = backend_changed,
 };
 
diff -r a1c2cede77c7 linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c	Mon Jul 10 14:01:49 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c	Tue Jul 11 09:21:36 2006
@@ -385,10 +385,10 @@
 	}
 }
 
-static int pciback_xenbus_probe(struct xenbus_device *dev,
-				const struct xenbus_device_id *id)
+static int pciback_xenbus_probe(struct device *device)
 {
 	int err = 0;
+	struct xenbus_device *dev = to_xenbus_device(device);
 	struct pciback_device *pdev = alloc_pdev(dev);
 
 	if (pdev == NULL) {
@@ -415,13 +415,13 @@
 	 */
 	pciback_be_watch(&pdev->be_watch, NULL, 0);
 
-      out:
-	return err;
-}
-
-static int pciback_xenbus_remove(struct xenbus_device *dev)
-{
-	struct pciback_device *pdev = dev->dev.driver_data;
+ out:
+	return err;
+}
+
+static int pciback_xenbus_remove(struct device *device)
+{
+	struct pciback_device *pdev = device->driver_data;
 
 	if (pdev != NULL)
 		free_pdev(pdev);
@@ -435,11 +435,11 @@
 };
 
 static struct xenbus_driver xenbus_pciback_driver = {
-	.name 			= "pciback",
-	.owner 			= THIS_MODULE,
 	.ids 			= xenpci_ids,
-	.probe 			= pciback_xenbus_probe,
-	.remove 		= pciback_xenbus_remove,
+	.driver.name 		= "pciback",
+	.driver.owner 	       	= THIS_MODULE,
+	.driver.probe		= pciback_xenbus_probe,
+	.driver.remove 		= pciback_xenbus_remove,
 	.otherend_changed 	= pciback_frontend_changed,
 };
 
diff -r a1c2cede77c7 linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c	Mon Jul 10 14:01:49 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c	Tue Jul 11 09:21:36 2006
@@ -240,10 +240,10 @@
 	}
 }
 
-static int pcifront_xenbus_probe(struct xenbus_device *xdev,
-				 const struct xenbus_device_id *id)
-{
-	int err = 0;
+static int pcifront_xenbus_probe(struct device *device)
+{
+	int err = 0;
+	struct xenbus_device *xdev = to_xenbus_device(device);
 	struct pcifront_device *pdev = alloc_pdev(xdev);
 
 	if (pdev == NULL) {
@@ -259,10 +259,10 @@
 	return err;
 }
 
-static int pcifront_xenbus_remove(struct xenbus_device *xdev)
-{
-	if (xdev->dev.driver_data)
-		free_pdev(xdev->dev.driver_data);
+static int pcifront_xenbus_remove(struct device *device)
+{
+	if (device->driver_data)
+		free_pdev(device->driver_data);
 
 	return 0;
 }
@@ -273,11 +273,11 @@
 };
 
 static struct xenbus_driver xenbus_pcifront_driver = {
-	.name 			= "pcifront",
-	.owner 			= THIS_MODULE,
 	.ids 			= xenpci_ids,
-	.probe 			= pcifront_xenbus_probe,
-	.remove 		= pcifront_xenbus_remove,
+	.driver.name		= "pcifront",
+	.driver.owner		= THIS_MODULE,
+	.driver.probe		= pcifront_xenbus_probe,
+	.driver.remove 		= pcifront_xenbus_remove,
 	.otherend_changed 	= pcifront_backend_changed,
 };
 
diff -r a1c2cede77c7 linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c	Mon Jul 10 14:01:49 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c	Tue Jul 11 09:21:36 2006
@@ -53,9 +53,9 @@
 	return res;
 }
 
-static int tpmback_remove(struct xenbus_device *dev)
-{
-	struct backend_info *be = dev->dev.driver_data;
+static int tpmback_remove(struct device *device)
+{
+	struct backend_info *be = device->driver_data;
 
 	if (!be) return 0;
 
@@ -71,14 +71,14 @@
 		be->tpmif = NULL;
 	}
 	kfree(be);
-	dev->dev.driver_data = NULL;
+	device->driver_data = NULL;
 	return 0;
 }
 
-static int tpmback_probe(struct xenbus_device *dev,
-			 const struct xenbus_device_id *id)
-{
-	int err;
+static int tpmback_probe(struct device *device)
+{
+	int err;
+	struct xenbus_device *dev = to_xenbus_device(device);
 	struct backend_info *be = kzalloc(sizeof(struct backend_info),
 					  GFP_KERNEL);
 
@@ -105,7 +105,7 @@
 	}
 	return 0;
 fail:
-	tpmback_remove(dev);
+	tpmback_remove(&dev->dev);
 	return err;
 }
 
@@ -164,7 +164,7 @@
 
 	case XenbusStateClosed:
 		device_unregister(&be->dev->dev);
-		tpmback_remove(dev);
+		tpmback_remove(&dev->dev);
 		break;
 
 	case XenbusStateUnknown:
@@ -271,11 +271,11 @@
 
 
 static struct xenbus_driver tpmback = {
-	.name = "vtpm",
-	.owner = THIS_MODULE,
 	.ids = tpmback_ids,
-	.probe = tpmback_probe,
-	.remove = tpmback_remove,
+	.driver.name   = "vtpm",
+	.driver.owner  = THIS_MODULE,
+	.driver.probe  = tpmback_probe,
+	.driver.remove = tpmback_remove,
 	.otherend_changed = frontend_changed,
 };
 
diff -r a1c2cede77c7 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Mon Jul 10 14:01:49 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Tue Jul 11 09:21:36 2006
@@ -58,6 +58,14 @@
 
 static struct notifier_block *xenstore_chain;
 
+/* fwd declarations */
+static int xenbus_probe_frontend(const char *type, const char *name);
+static int xenbus_probe_backend(const char *type, const char *domid);
+static int xenbus_uevent_backend(struct device *dev, char **envp,
+				 int num_envp, char *buffer, int buffer_size);
+static int xenbus_dev_probe(struct device *device);
+static int xenbus_dev_remove(struct device *device);
+
 /* If something in array of ids matches this device, return it. */
 static const struct xenbus_device_id *
 match_device(const struct xenbus_device_id *arr, struct xenbus_device *dev)
@@ -164,15 +172,16 @@
 
 
 /* Bus type for frontend drivers. */
-static int xenbus_probe_frontend(const char *type, const char *name);
 static struct xen_bus_type xenbus_frontend = {
 	.root = "device",
 	.levels = 2, 		/* device/type/<id> */
 	.get_bus_id = frontend_bus_id,
 	.probe = xenbus_probe_frontend,
 	.bus = {
-		.name  = "xen",
-		.match = xenbus_match,
+		.name     = "xen",
+		.match    = xenbus_match,
+		.probe    = xenbus_dev_probe,
+		.remove   = xenbus_dev_remove,
 	},
 	.dev = {
 		.bus_id = "xen",
@@ -217,18 +226,17 @@
 	return 0;
 }
 
-static int xenbus_uevent_backend(struct device *dev, char **envp,
-				 int num_envp, char *buffer, int buffer_size);
-static int xenbus_probe_backend(const char *type, const char *domid);
 static struct xen_bus_type xenbus_backend = {
 	.root = "backend",
 	.levels = 3, 		/* backend/type/<frontend>/<id> */
 	.get_bus_id = backend_bus_id,
 	.probe = xenbus_probe_backend,
 	.bus = {
-		.name  = "xen-backend",
-		.match = xenbus_match,
-		.uevent = xenbus_uevent_backend,
+		.name     = "xen-backend",
+		.match    = xenbus_match,
+		.probe    = xenbus_dev_probe,
+		.remove   = xenbus_dev_remove,
+		.uevent   = xenbus_uevent_backend,
 	},
 	.dev = {
 		.bus_id = "xen-backend",
@@ -243,7 +251,7 @@
 	int i = 0;
 	int length = 0;
 
-	DPRINTK("");
+	DPRINTK("%s", to_xenbus_device(dev)->nodename);
 
 	if (dev == NULL)
 		return -ENODEV;
@@ -323,16 +331,16 @@
 }
 
 
-static int xenbus_dev_probe(struct device *_dev)
-{
-	struct xenbus_device *dev = to_xenbus_device(_dev);
-	struct xenbus_driver *drv = to_xenbus_driver(_dev->driver);
+static int xenbus_dev_probe(struct device *device)
+{
+	struct xenbus_device *dev = to_xenbus_device(device);
+	struct xenbus_driver *drv = to_xenbus_driver(device->driver);
 	const struct xenbus_device_id *id;
 	int err;
 
-	DPRINTK("");
-
-	if (!drv->probe) {
+	DPRINTK("%s", to_xenbus_device(device)->nodename);
+
+	if (!device->driver->probe) {
 		err = -ENODEV;
 		goto fail;
 	}
@@ -351,7 +359,7 @@
 		return err;
 	}
 
-	err = drv->probe(dev, id);
+	err = device->driver->probe(device);
 	if (err)
 		goto fail;
 
@@ -370,18 +378,17 @@
 	return -ENODEV;
 }
 
-static int xenbus_dev_remove(struct device *_dev)
-{
-	struct xenbus_device *dev = to_xenbus_device(_dev);
-	struct xenbus_driver *drv = to_xenbus_driver(_dev->driver);
-
-	DPRINTK("");
+static int xenbus_dev_remove(struct device *device)
+{
+	struct xenbus_device *dev = to_xenbus_device(device);
+
+	DPRINTK("%s", dev->nodename);
 
 	free_otherend_watch(dev);
 	free_otherend_details(dev);
 
-	if (drv->remove)
-		drv->remove(dev);
+	if (device->driver->remove)
+		device->driver->remove(device);
 
 	xenbus_switch_state(dev, XenbusStateClosed);
 	return 0;
@@ -392,11 +399,7 @@
 {
 	int ret;
 
-	drv->driver.name = drv->name;
 	drv->driver.bus = &bus->bus;
-	drv->driver.owner = drv->owner;
-	drv->driver.probe = xenbus_dev_probe;
-	drv->driver.remove = xenbus_dev_remove;
 
 	mutex_lock(&xenwatch_mutex);
 	ret = driver_register(&drv->driver);
@@ -614,7 +617,7 @@
 	if (!nodename)
 		return -ENOMEM;
 
-	DPRINTK("%s\n", nodename);
+	DPRINTK("%s", nodename);
 
 	err = xenbus_probe_node(&xenbus_backend, type, nodename);
 	kfree(nodename);
@@ -777,56 +780,50 @@
 	.callback = backend_changed,
 };
 
-static int suspend_dev(struct device *dev, void *data)
+static int suspend_dev(struct device *device, void *data)
 {
 	int err = 0;
-	struct xenbus_driver *drv;
-	struct xenbus_device *xdev;
-
-	DPRINTK("");
-
-	if (dev->driver == NULL)
+
+	DPRINTK("%s",  to_xenbus_device(device)->nodename);
+
+	if (device->driver == NULL)
 		return 0;
-	drv = to_xenbus_driver(dev->driver);
-	xdev = container_of(dev, struct xenbus_device, dev);
-	if (drv->suspend)
-		err = drv->suspend(xdev);
+	if (device->driver->suspend)
+		err = device->driver->suspend(device, PMSG_FREEZE);
 	if (err)
 		printk(KERN_WARNING
-		       "xenbus: suspend %s failed: %i\n", dev->bus_id, err);
-	return 0;
-}
-
-static int resume_dev(struct device *dev, void *data)
+		       "xenbus: suspend %s failed: %i\n", device->bus_id, err);
+	return 0;
+}
+
+static int resume_dev(struct device *device, void *data)
 {
 	int err;
-	struct xenbus_driver *drv;
 	struct xenbus_device *xdev;
 
-	DPRINTK("");
-
-	if (dev->driver == NULL)
+	DPRINTK("%s", to_xenbus_device(device)->nodename);
+
+	if (device->driver == NULL)
 		return 0;
 
-	drv = to_xenbus_driver(dev->driver);
-	xdev = container_of(dev, struct xenbus_device, dev);
+	xdev = to_xenbus_device(device);
 
 	err = talk_to_otherend(xdev);
 	if (err) {
 		printk(KERN_WARNING
 		       "xenbus: resume (talk_to_otherend) %s failed: %i\n",
-		       dev->bus_id, err);
+		       device->bus_id, err);
 		return err;
 	}
 
 	xdev->state = XenbusStateInitialising;
 
-	if (drv->resume) {
-		err = drv->resume(xdev);
+	if (device->driver->resume) {
+		err = device->driver->resume(device);
 		if (err) { 
 			printk(KERN_WARNING
 			       "xenbus: resume %s failed: %i\n", 
-			       dev->bus_id, err);
+			       device->bus_id, err);
 			return err; 
 		}
 	}
@@ -835,7 +832,7 @@
 	if (err) {
 		printk(KERN_WARNING
 		       "xenbus_probe: resume (watch_otherend) %s failed: "
-		       "%d.\n", dev->bus_id, err);
+		       "%d.\n", device->bus_id, err);
 		return err;
 	}
 
@@ -846,6 +843,8 @@
 {
 	DPRINTK("");
 
+	/* Hmm, device_suspend() should be able to suspend all the
+	 * devices for us, we'll depend on CONFIG_PM then though. */
 	bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_dev);
 	bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, suspend_dev);
 	xs_suspend();
diff -r a1c2cede77c7 linux-2.6-xen-sparse/include/xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/xen/xenbus.h	Mon Jul 10 14:01:49 2006
+++ b/linux-2.6-xen-sparse/include/xen/xenbus.h	Tue Jul 11 09:21:36 2006
@@ -89,19 +89,12 @@
 
 /* A xenbus driver. */
 struct xenbus_driver {
-	char *name;
-	struct module *owner;
 	const struct xenbus_device_id *ids;
-	int (*probe)(struct xenbus_device *dev,
-		     const struct xenbus_device_id *id);
+	struct device_driver driver;
 	void (*otherend_changed)(struct xenbus_device *dev,
 				 enum xenbus_state backend_state);
-	int (*remove)(struct xenbus_device *dev);
-	int (*suspend)(struct xenbus_device *dev);
-	int (*resume)(struct xenbus_device *dev);
+	int (*read_otherend_details)(struct xenbus_device *dev);
 	int (*uevent)(struct xenbus_device *, char **, int, char *, int);
-	struct device_driver driver;
-	int (*read_otherend_details)(struct xenbus_device *dev);
 };
 
 static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv)

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2006-07-11  7:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-11  7:32 Gerd Hoffmann [this message]
2006-07-11 11:41 ` [PATCH] cleanup "struct xenbus_driver" Gerd Hoffmann
2006-07-11 15:08   ` Keir Fraser
2006-07-11 15:54     ` Gerd Hoffmann
2006-07-11 16:03       ` Keir Fraser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44B3542A.20301@suse.de \
    --to=kraxel@suse.de \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.