[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Simplify code by making in and out pointers internal to xenbus_xs.c



# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 3be03cd7cd4c670655ce086050fba71c0cf6a957
# Parent  c02e5214247ee75f9cfa3d89b9792110c324cc3d
Simplify code by making in and out pointers internal to xenbus_xs.c
Signed-off-by: Rusty Russel <rusty@xxxxxxxxxxxxxxx>
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r c02e5214247e -r 3be03cd7cd4c 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c    Wed Jul 27 
18:41:49 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c    Thu Jul 28 
12:25:13 2005
@@ -47,6 +47,17 @@
 
 DECLARE_WAIT_QUEUE_HEAD(xb_waitq);
 
+static inline struct ringbuf_head *outbuf(void)
+{
+       return machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT);
+}
+
+static inline struct ringbuf_head *inbuf(void)
+{
+       return machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT)
+               + PAGE_SIZE/2;
+}
+
 static irqreturn_t wake_waiting(int irq, void *unused, struct pt_regs *regs)
 {
        wake_up(&xb_waitq);
@@ -108,9 +119,10 @@
        return avail != 0;
 }
 
-int xb_write(struct ringbuf_head *out, const void *data, unsigned len)
+int xb_write(const void *data, unsigned len)
 {
        struct ringbuf_head h;
+       struct ringbuf_head *out = outbuf();
 
        do {
                void *dst;
@@ -141,24 +153,26 @@
        return 0;
 }
 
-int xs_input_avail(struct ringbuf_head *in)
+int xs_input_avail(void)
 {
        unsigned int avail;
+       struct ringbuf_head *in = inbuf();
 
        get_input_chunk(in, in->buf, &avail);
        return avail != 0;
 }
 
-int xb_read(struct ringbuf_head *in, void *data, unsigned len)
+int xb_read(void *data, unsigned len)
 {
        struct ringbuf_head h;
+       struct ringbuf_head *in = inbuf();
        int was_full;
 
        while (len != 0) {
                unsigned int avail;
                const char *src;
 
-               wait_event(xb_waitq, xs_input_avail(in));
+               wait_event(xb_waitq, xs_input_avail());
                h = *in;
                mb();
                if (!check_buffer(&h)) {
@@ -182,14 +196,14 @@
        }
 
        /* If we left something, wake watch thread to deal with it. */
-       if (xs_input_avail(in))
+       if (xs_input_avail())
                wake_up(&xb_waitq);
 
        return 0;
 }
 
 /* Set up interrpt handler off store event channel. */
-int xb_init_comms(void **in, void **out)
+int xb_init_comms(void)
 {
        int err, irq;
 
@@ -202,11 +216,9 @@
                return err;
        }
 
-       *out = machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT);
-       *in = *out + PAGE_SIZE / 2;
-
        /* FIXME zero out page -- domain builder should probably do this*/
-       memset(*out, 0, PAGE_SIZE);
+       memset(machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT),
+              0, PAGE_SIZE);
 
        return 0;
 }
diff -r c02e5214247e -r 3be03cd7cd4c 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h    Wed Jul 27 
18:41:49 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h    Thu Jul 28 
12:25:13 2005
@@ -2,13 +2,12 @@
 #ifndef _XENBUS_COMMS_H
 #define _XENBUS_COMMS_H
 int xs_init(void);
-int xb_init_comms(void **in, void **out);
+int xb_init_comms(void);
 
 /* Low level routines. */
-struct ringbuf_head;
-int xb_write(struct ringbuf_head *out, const void *data, unsigned len);
-int xb_read(struct ringbuf_head *in, void *data, unsigned len);
-int xs_input_avail(struct ringbuf_head *in);
+int xb_write(const void *data, unsigned len);
+int xb_read(void *data, unsigned len);
+int xs_input_avail(void);
 extern wait_queue_head_t xb_waitq;
 
 #endif /* _XENBUS_COMMS_H */
diff -r c02e5214247e -r 3be03cd7cd4c 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c       Wed Jul 27 
18:41:49 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c       Thu Jul 28 
12:25:13 2005
@@ -44,7 +44,6 @@
 #define streq(a, b) (strcmp((a), (b)) == 0)
 
 static char printf_buffer[4096];
-static void *xs_in, *xs_out;
 static LIST_HEAD(watches);
 DECLARE_MUTEX(xenbus_lock);
 
@@ -69,7 +68,7 @@
        void *ret;
        int err;
 
-       err = xb_read(xs_in, &msg, sizeof(msg));
+       err = xb_read(&msg, sizeof(msg));
        if (err)
                return ERR_PTR(err);
 
@@ -77,7 +76,7 @@
        if (!ret)
                return ERR_PTR(-ENOMEM);
 
-       err = xb_read(xs_in, ret, msg.len);
+       err = xb_read(ret, msg.len);
        if (err) {
                kfree(ret);
                return ERR_PTR(err);
@@ -94,15 +93,14 @@
 void xenbus_debug_write(const char *str, unsigned int count)
 {
        struct xsd_sockmsg msg;
-       void *out = machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT);
 
        msg.type = XS_DEBUG;
        msg.len = sizeof("print") + count + 1;
 
-       xb_write(out, &msg, sizeof(msg));
-       xb_write(out, "print", sizeof("print"));
-       xb_write(out, str, count);
-       xb_write(out, "", 1);
+       xb_write(&msg, sizeof(msg));
+       xb_write("print", sizeof("print"));
+       xb_write(str, count);
+       xb_write("", 1);
 }
 
 /* Send message to xs, get kmalloc'ed reply.  ERR_PTR() on error. */
@@ -123,12 +121,12 @@
        for (i = 0; i < num_vecs; i++)
                msg.len += iovec[i].iov_len;
 
-       err = xb_write(xs_out, &msg, sizeof(msg));
+       err = xb_write(&msg, sizeof(msg));
        if (err)
                return ERR_PTR(err);
 
        for (i = 0; i < num_vecs; i++) {
-               err = xb_write(xs_out, iovec[i].iov_base, iovec[i].iov_len);;
+               err = xb_write(iovec[i].iov_base, iovec[i].iov_len);;
                if (err)
                        return ERR_PTR(err);
        }
@@ -509,14 +507,14 @@
                char *token;
                char *node = NULL;
 
-               wait_event(xb_waitq, xs_input_avail(xs_in));
+               wait_event(xb_waitq, xs_input_avail());
 
                /* If this is a spurious wakeup caused by someone
                 * doing an op, they'll hold the lock and the buffer
                 * will be empty by the time we get there.               
                 */
                down(&xenbus_lock);
-               if (xs_input_avail(xs_in))
+               if (xs_input_avail())
                        node = xs_read_watch(&token);
 
                if (node && !IS_ERR(node)) {
@@ -548,7 +546,7 @@
        int err;
        struct task_struct *watcher;
 
-       err = xb_init_comms(&xs_in, &xs_out);
+       err = xb_init_comms();
        if (err)
                return err;
        

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.