All of lore.kernel.org
 help / color / mirror / Atom feed
* xenbus_backend_client.c / xenbus_client.c merger
@ 2007-02-19 14:00 Kieran Mansley
  2007-02-19 15:17 ` Keir Fraser
  0 siblings, 1 reply; 6+ messages in thread
From: Kieran Mansley @ 2007-02-19 14:00 UTC (permalink / raw)
  To: xen-devel

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

Although I don't know the full history, it looks like at some point
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c was
created to hold "backend only" code that would otherwise be in
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c.

However, the code in xenbus_backend_client.c isn't currently specific to
the backend - it just happens to be that no frontends use it.  At least
that's how it looks to me.

A frontend I'm working on (and have submitted here as a patch a few
times) does use this "backend only" code.  In particular the
xenbus_map_ring family of functions.  I would therefore like to move
this from xenbus_backend_client.c into xenbus_client.c.  This would
leave xenbus_backend_client.c containing just xenbus_dev_is_online()
which also looks potentially useful to a frontend, and so I propose
moving that too and then removing the xenbus_backend_client.c file
altogether.

Does anyone have any comments on this change?  I'm happy to submit a
patch for it (e.g. see attached).  In particular, if anyone is aware of
the reason for this code split that would be interesting as I like to
understand things I'm changing!

Functionally this only affects those using separate domU/dom0 kernels.
If using a unified kernel the symbols from both files were available in
both domains regardless.

Thanks

Kieran

[-- Attachment #2: xenbus_backend_client --]
[-- Type: text/plain, Size: 8794 bytes --]

Merge xenbus_backend_client.c with xenbus_client.c

diff -r b5fc88aad1b0 linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile	Sun Feb 18 15:29:40 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile	Mon Feb 19 13:56:52 2007 +0000
@@ -1,8 +1,5 @@ obj-y += xenbus_client.o xenbus_comms.o 
 obj-y += xenbus_client.o xenbus_comms.o xenbus_xs.o xenbus_probe.o
 obj-$(CONFIG_XEN_BACKEND) += xenbus_be.o
-
-xenbus_be-objs =
-xenbus_be-objs += xenbus_backend_client.o
 
 xenbus-$(CONFIG_XEN_BACKEND) += xenbus_probe_backend.o
 obj-y += $(xenbus-y) $(xenbus-m)
diff -r b5fc88aad1b0 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Sun Feb 18 15:29:40 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Mon Feb 19 13:56:54 2007 +0000
@@ -281,3 +281,113 @@ enum xenbus_state xenbus_read_driver_sta
 	return result;
 }
 EXPORT_SYMBOL_GPL(xenbus_read_driver_state);
+
+
+/* Based on Rusty Russell's skeleton driver's map_page */
+struct vm_struct *xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref)
+{
+	struct gnttab_map_grant_ref op;
+	struct vm_struct *area;
+
+	area = alloc_vm_area(PAGE_SIZE);
+	if (!area)
+		return ERR_PTR(-ENOMEM);
+
+	gnttab_set_map_op(&op, (unsigned long)area->addr, GNTMAP_host_map,
+			  gnt_ref, dev->otherend_id);
+	
+	if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
+		BUG();
+
+	if (op.status != GNTST_okay) {
+		free_vm_area(area);
+		xenbus_dev_fatal(dev, op.status,
+				 "mapping in shared page %d from domain %d",
+				 gnt_ref, dev->otherend_id);
+		BUG_ON(!IS_ERR(ERR_PTR(op.status)));
+		return ERR_PTR(op.status);
+	}
+
+	/* Stuff the handle in an unused field */
+	area->phys_addr = (unsigned long)op.handle;
+
+	return area;
+}
+EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc);
+
+
+int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
+		   grant_handle_t *handle, void *vaddr)
+{
+	struct gnttab_map_grant_ref op;
+	
+	gnttab_set_map_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
+			  gnt_ref, dev->otherend_id);
+	if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
+		BUG();
+
+	if (op.status != GNTST_okay) {
+		xenbus_dev_fatal(dev, op.status,
+				 "mapping in shared page %d from domain %d",
+				 gnt_ref, dev->otherend_id);
+	} else
+		*handle = op.handle;
+
+	return op.status;
+}
+EXPORT_SYMBOL_GPL(xenbus_map_ring);
+
+
+/* Based on Rusty Russell's skeleton driver's unmap_page */
+int xenbus_unmap_ring_vfree(struct xenbus_device *dev, struct vm_struct *area)
+{
+	struct gnttab_unmap_grant_ref op;
+
+	gnttab_set_unmap_op(&op, (unsigned long)area->addr, GNTMAP_host_map,
+			    (grant_handle_t)area->phys_addr);
+
+	if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
+		BUG();
+
+	if (op.status == GNTST_okay)
+		free_vm_area(area);
+	else
+		xenbus_dev_error(dev, op.status,
+				 "unmapping page at handle %d error %d",
+				 (int16_t)area->phys_addr, op.status);
+
+	return op.status;
+}
+EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree);
+
+
+int xenbus_unmap_ring(struct xenbus_device *dev,
+		     grant_handle_t handle, void *vaddr)
+{
+	struct gnttab_unmap_grant_ref op;
+
+	gnttab_set_unmap_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
+			    handle);
+	if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
+		BUG();
+
+	if (op.status != GNTST_okay)
+		xenbus_dev_error(dev, op.status,
+				 "unmapping page at handle %d error %d",
+				 handle, op.status);
+
+	return op.status;
+}
+EXPORT_SYMBOL_GPL(xenbus_unmap_ring);
+
+int xenbus_dev_is_online(struct xenbus_device *dev)
+{
+	int rc, val;
+
+	rc = xenbus_scanf(XBT_NIL, dev->nodename, "online", "%d", &val);
+	if (rc != 1)
+		val = 0; /* no online node present */
+
+	return val;
+}
+EXPORT_SYMBOL_GPL(xenbus_dev_is_online);
diff -r b5fc88aad1b0 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c	Sun Feb 18 15:29:40 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-/******************************************************************************
- * Backend-client-facing interface for the Xenbus driver.  In other words, the
- * interface between the Xenbus and the device-specific code in the backend
- * driver.
- *
- * Copyright (C) 2005-2006 XenSource Ltd
- * 
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation; or, when distributed
- * separately from the Linux kernel or incorporated into other
- * software packages, subject to the following license:
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this source file (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy, modify,
- * merge, publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#include <linux/err.h>
-#include <xen/gnttab.h>
-#include <xen/xenbus.h>
-#include <xen/driver_util.h>
-
-/* Based on Rusty Russell's skeleton driver's map_page */
-struct vm_struct *xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref)
-{
-	struct gnttab_map_grant_ref op;
-	struct vm_struct *area;
-
-	area = alloc_vm_area(PAGE_SIZE);
-	if (!area)
-		return ERR_PTR(-ENOMEM);
-
-	gnttab_set_map_op(&op, (unsigned long)area->addr, GNTMAP_host_map,
-			  gnt_ref, dev->otherend_id);
-	
-	if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
-		BUG();
-
-	if (op.status != GNTST_okay) {
-		free_vm_area(area);
-		xenbus_dev_fatal(dev, op.status,
-				 "mapping in shared page %d from domain %d",
-				 gnt_ref, dev->otherend_id);
-		BUG_ON(!IS_ERR(ERR_PTR(op.status)));
-		return ERR_PTR(op.status);
-	}
-
-	/* Stuff the handle in an unused field */
-	area->phys_addr = (unsigned long)op.handle;
-
-	return area;
-}
-EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc);
-
-
-int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
-		   grant_handle_t *handle, void *vaddr)
-{
-	struct gnttab_map_grant_ref op;
-	
-	gnttab_set_map_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
-			  gnt_ref, dev->otherend_id);
-	if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
-		BUG();
-
-	if (op.status != GNTST_okay) {
-		xenbus_dev_fatal(dev, op.status,
-				 "mapping in shared page %d from domain %d",
-				 gnt_ref, dev->otherend_id);
-	} else
-		*handle = op.handle;
-
-	return op.status;
-}
-EXPORT_SYMBOL_GPL(xenbus_map_ring);
-
-
-/* Based on Rusty Russell's skeleton driver's unmap_page */
-int xenbus_unmap_ring_vfree(struct xenbus_device *dev, struct vm_struct *area)
-{
-	struct gnttab_unmap_grant_ref op;
-
-	gnttab_set_unmap_op(&op, (unsigned long)area->addr, GNTMAP_host_map,
-			    (grant_handle_t)area->phys_addr);
-
-	if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
-		BUG();
-
-	if (op.status == GNTST_okay)
-		free_vm_area(area);
-	else
-		xenbus_dev_error(dev, op.status,
-				 "unmapping page at handle %d error %d",
-				 (int16_t)area->phys_addr, op.status);
-
-	return op.status;
-}
-EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree);
-
-
-int xenbus_unmap_ring(struct xenbus_device *dev,
-		     grant_handle_t handle, void *vaddr)
-{
-	struct gnttab_unmap_grant_ref op;
-
-	gnttab_set_unmap_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
-			    handle);
-	if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
-		BUG();
-
-	if (op.status != GNTST_okay)
-		xenbus_dev_error(dev, op.status,
-				 "unmapping page at handle %d error %d",
-				 handle, op.status);
-
-	return op.status;
-}
-EXPORT_SYMBOL_GPL(xenbus_unmap_ring);
-
-int xenbus_dev_is_online(struct xenbus_device *dev)
-{
-	int rc, val;
-
-	rc = xenbus_scanf(XBT_NIL, dev->nodename, "online", "%d", &val);
-	if (rc != 1)
-		val = 0; /* no online node present */
-
-	return val;
-}
-EXPORT_SYMBOL_GPL(xenbus_dev_is_online);
-
-MODULE_LICENSE("Dual BSD/GPL");

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

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-02-19 17:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-19 14:00 xenbus_backend_client.c / xenbus_client.c merger Kieran Mansley
2007-02-19 15:17 ` Keir Fraser
2007-02-19 16:08   ` Kieran Mansley
2007-02-19 16:50     ` Keir Fraser
2007-02-19 17:07       ` Kieran Mansley
2007-02-19 17:48         ` Keir Fraser

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.