WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Fix bus watch code, and clean up a little.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Fix bus watch code, and clean up a little.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 26 Jul 2005 20:26:18 -0400
Delivery-date: Wed, 27 Jul 2005 00:27:55 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID c1c2a023dbc49bec7d6bdbd65514f91649b7e422
# Parent  51fb35494e9b75ca1ffd240fb01822aa0f0e9012
Fix bus watch code, and clean up a little.
Signed-off-by: Rusty Russel <rusty@xxxxxxxxxxxxxxx>
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 51fb35494e9b -r c1c2a023dbc4 
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 
17:18:55 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Tue Jul 26 
17:19:38 2005
@@ -233,29 +233,25 @@
 static void dev_changed(struct xenbus_watch *watch, const char *node)
 {
        char busid[BUS_ID_SIZE];
-       unsigned int typelen, idlen;
        int exists;
        struct xenbus_device *dev;
-       char *type;
+       char *p;
 
        /* Node is of form device/<type>/<identifier>[/...] */
-       if (char_count(node, '/') != 3)
+       if (char_count(node, '/') != 2)
                return;
 
-       type = strchr(node, '/');
-       type++;
-       typelen = strcspn(type, "/");
-       idlen = strcspn(type + typelen + 1, "/");
-       if (typelen + strlen("-") + idlen + 1 > BUS_ID_SIZE) {
+       /* Created or deleted? */
+       exists = xenbus_exists(node, "");
+
+       p = strchr(node, '/') + 1;
+       if (strlen(p) + 1 > BUS_ID_SIZE) {
                printk("Device for node %s is too big!\n", node);
                return;
        }
-
-       /* Does it exist? */
-       exists = xenbus_exists(node, "");
-
-       /* Create it with a / so we can see if it exists. */
-       sprintf(busid, "%.*s-%.*s", typelen, type, idlen, type + typelen + 1);
+       /* Bus ID is name with / changed to - */
+       strcpy(busid, p);
+       *strchr(busid, '/') = '-';
 
        dev = xenbus_device_find(busid);
        printk("xenbus: device %s %s\n", busid, dev ? "exists" : "new");
@@ -263,12 +259,14 @@
                printk("xenbus: Unregistering device %s\n", busid);
                /* FIXME: free? */
                device_unregister(&dev->dev);
-       }
-       if (!dev && exists) {
+       } else if (!dev && exists) {
                printk("xenbus: Adding device %s\n", busid);
-               busid[typelen] = '\0';
-               xenbus_probe_device("device", busid, busid+typelen+1);
-       }
+               /* Hack bus id back into two strings. */
+               *strrchr(busid, '-') = '\0';
+               xenbus_probe_device("device", busid, busid+strlen(busid)+1);
+       } else
+               printk("xenbus: strange, %s already %s\n", busid,
+                      exists ? "exists" : "gone");
        if (dev)
                put_device(&dev->dev);
 }

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Fix bus watch code, and clean up a little., Xen patchbot -unstable <=