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

[Xen-changelog] Fix return from xenbus_scanf: returns number scanned, not 0!



# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 42e8937a93f077f31b7d687308d7789c039dbd77
# Parent  2e6e1eb66c5e51759ffcb04f95cb3ffa1f1cf4f2
Fix return from xenbus_scanf: returns number scanned, not 0!
Fix xenbus_write args in xenbus_printf
Signed-off-by: Rusty Russel <rusty@xxxxxxxxxxxxxxx>
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 2e6e1eb66c5e -r 42e8937a93f0 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Tue Jul 26 
16:59:40 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Tue Jul 26 
17:04:33 2005
@@ -1,6 +1,5 @@
 /******************************************************************************
  * Talks to Xen Store to figure out what devices we have.
- * Currently experiment code, but when I grow up I'll be a bus driver!
  *
  * Copyright (C) 2005 Rusty Russell, IBM Corporation
  * Copyright (C) 2005 Mike Wray, Hewlett-Packard
@@ -38,11 +37,6 @@
 #include <stdarg.h>
 #include "xenbus_comms.h"
 
-/* Name of field containing device type. */
-#define XENBUS_DEVICE_TYPE "type"
-
-static int xs_init_done = 0;
-
 #define streq(a, b) (strcmp((a), (b)) == 0)
 
 /* If something in array of ids matches this device, return it. */
@@ -83,18 +77,13 @@
        struct xenbus_driver *drv = to_xenbus_driver(_dev->driver);
        const struct xenbus_device_id *id;
 
-       printk("Probing device '%s'\n", _dev->bus_id);
-       if (!drv->probe) {
-               printk("'%s' no probefn\n", _dev->bus_id);
+       if (!drv->probe)
                return -ENODEV;
-       }
 
        id = match_device(drv->ids, dev);
-       if (!id) {
-               printk("'%s' no id match\n", _dev->bus_id);
+       if (!id)
                return -ENODEV;
-       }
-       printk("probing '%s' fn %p\n", _dev->bus_id, drv->probe);
+
        return drv->probe(dev, id);
 }
 
@@ -125,94 +114,80 @@
 }
 
 /* devices/<typename>/<name> */
-static int xenbus_probe_device(const char *typename, const char *name)
+static int xenbus_probe_device(const char *dirpath, const char *devicetype,
+                              const char *name)
 {
        int err;
        struct xenbus_device *xendev;
        unsigned int stringlen;
 
-       pr_debug("> dir=%s name=%s\n", typename, name);
-
        /* FIXME: This could be a rescan. Don't re-register existing devices. */
 
        /* Nodename: /device/<typename>/<name>/ */
-       stringlen = strlen("device") + strlen(typename) + strlen(name) + 3;
+       stringlen = strlen(dirpath) + strlen(devicetype) + strlen(name) + 3;
        /* Typename */
-       stringlen += strlen(typename) + 1;
-
+       stringlen += strlen(devicetype) + 1;
        xendev = kmalloc(sizeof(*xendev) + stringlen, GFP_KERNEL);
        if (!xendev)
                return -ENOMEM;
-
        memset(xendev, 0, sizeof(*xendev));
+
        /* Copy the strings into the extra space. */
        xendev->nodename = (char *)(xendev + 1);
-       sprintf(xendev->nodename, "%s/%s/%s", "device", typename, name);
+       sprintf(xendev->nodename, "%s/%s/%s", dirpath, devicetype, name);
        xendev->devicetype = xendev->nodename + strlen(xendev->nodename) + 1;
-       strcpy(xendev->devicetype, typename);
+       strcpy(xendev->devicetype, devicetype);
 
        /* FIXME: look for "subtype" field. */
-       snprintf(xendev->dev.bus_id, BUS_ID_SIZE, "%s-%s", typename, name);
+       snprintf(xendev->dev.bus_id, BUS_ID_SIZE, "%s-%s", devicetype, name);
        xendev->dev.bus = &xenbus_type;
 
        /* Register with generic device framework. */
-       printk("XENBUS: Registering device %s\n", xendev->dev.bus_id);
        err = device_register(&xendev->dev);
        if (err) {
                printk("XENBUS: Registering device %s: error %i\n",
                       xendev->dev.bus_id, err);
                kfree(xendev);
        }
-
-       pr_debug("< err=%i\n", err);
        return err;
 }
 
-/* /device/<typename> */
-static int xenbus_probe_device_type(const char *typename)
+static int xenbus_probe_device_type(const char *dirpath, const char *typename)
 {
        int err = 0;
        char **dir;
        unsigned int dir_n = 0;
        int i;
 
-       dir = xenbus_directory("device", typename, &dir_n);
-       printk("dir %s has %u entries\n", typename, dir_n);
-       if (IS_ERR(dir)) {
-               printk("dir %s returned %li\n", typename, PTR_ERR(dir));
+       dir = xenbus_directory(dirpath, typename, &dir_n);
+       if (IS_ERR(dir))
                return PTR_ERR(dir);
-       }
 
        for (i = 0; i < dir_n; i++) {
-               printk("Probing %s/%s\n", dir[i], typename);
-               err = xenbus_probe_device(dir[i], typename);
+               err = xenbus_probe_device(dirpath, typename, dir[i]);
                if (err)
                        break;
        }
        kfree(dir);
-       pr_debug("< err=%i\n", err);
        return err;
 }
 
-static int xenbus_probe_devices(void)
+static int xenbus_probe_devices(const char *path)
 {
        int err = 0;
        char **dir;
        unsigned int i, dir_n;
 
        down(&xenbus_lock);
-       dir = xenbus_directory("device", "", &dir_n);
+       dir = xenbus_directory(path, "", &dir_n);
        if (IS_ERR(dir)) {
                err = PTR_ERR(dir);
                goto unlock;
        }
        for (i = 0; i < dir_n; i++) {
-               err = xenbus_probe_device_type(dir[i]);
-               if (err) {
-                       printk("xenbus: error %i probing device %s\n",
-                              -err, dir[i]);
+               err = xenbus_probe_device_type(path, dir[i]);
+               if (err)
                        break;
-               }
        }
        kfree(dir);
 unlock:
@@ -225,25 +200,18 @@
 {
        int err = 0;
 
-       printk("%s> xs_init_done=%d\n", __FUNCTION__, xs_init_done);
-       if (xs_init_done)
-               goto exit;
        /* Initialize xenstore comms unless already done. */
        printk("store_evtchn = %i\n", xen_start_info.store_evtchn);
        err = xs_init();
        if (err) {
                printk("XENBUS: Error initializing xenstore comms:"
                       " %i\n", err);
-               goto exit;
-       }
-       xs_init_done = 1;
+               return err;
+       }
 
        /* Enumerate devices in xenstore. */
-       xenbus_probe_devices();
-
-exit:
-       printk("%s< err=%d\n", __FUNCTION__, err);
-       return err;
+       xenbus_probe_devices("device");
+       return 0;
 }
 
 static int __init xenbus_probe_init(void)
diff -r 2e6e1eb66c5e -r 42e8937a93f0 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c       Tue Jul 26 
16:59:40 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c       Tue Jul 26 
17:04:33 2005
@@ -347,8 +347,7 @@
        va_end(ap);
 
        BUG_ON(ret > sizeof(buffer)-1);
-
-       return xenbus_write(dir, node, buffer, ret+1);
+       return xenbus_write(dir, node, buffer, O_CREAT);
 }
 
 /* Takes tuples of names, scanf-style args, and void **, NULL terminated. */
diff -r 2e6e1eb66c5e -r 42e8937a93f0 
linux-2.6-xen-sparse/include/asm-xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h     Tue Jul 26 16:59:40 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h     Tue Jul 26 17:04:33 2005
@@ -59,8 +59,7 @@
        const struct xenbus_device_id *ids;
        int  (*probe)    (struct xenbus_device * dev,
                          const struct xenbus_device_id * id);
-        int  (*remove)   (struct xenbus_device * dev);
-
+       int  (*remove)   (struct xenbus_device * dev);
        struct device_driver driver;
 };
 

_______________________________________________
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®.