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 locking: probe can be called from several places, so

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Fix locking: probe can be called from several places, so ensure
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 26 Jul 2005 20:26:19 -0400
Delivery-date: Wed, 27 Jul 2005 00:27:58 +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 b5219630030688d67a6454c21d9a3aa400009ef1
# Parent  c1c2a023dbc49bec7d6bdbd65514f91649b7e422
Fix locking: probe can be called from several places, so ensure
we lock for it.
Signed-off-by: Rusty Russel <rusty@xxxxxxxxxxxxxxx>
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r c1c2a023dbc4 -r b52196300306 
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:19:38 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Tue Jul 26 
17:22:38 2005
@@ -47,10 +47,13 @@
                if (!streq(arr->devicetype, dev->devicetype))
                        continue;
 
-               if (streq(arr->subtype, "") ||
-                   streq(arr->subtype, dev->subtype)) {
+               /* If they don't care what subtype, it's a match. */
+               if (streq(arr->subtype, ""))
                        return arr;
-               }
+
+               /* If they care, device must have (same) subtype. */
+               if (dev->subtype && streq(arr->subtype, dev->subtype))
+                       return arr;
        }
        return NULL;
 }
@@ -99,18 +102,25 @@
 
 int xenbus_register_driver(struct xenbus_driver *drv)
 {
+       int err;
+
        drv->driver.name = drv->name;
        drv->driver.bus = &xenbus_type;
        drv->driver.owner = drv->owner;
        drv->driver.probe = xenbus_dev_probe;
        drv->driver.remove = xenbus_dev_remove;
 
-       return driver_register(&drv->driver);
+       down(&xenbus_lock);
+       err = driver_register(&drv->driver);
+       up(&xenbus_lock);
+       return err;
 }
 
 void xenbus_unregister_driver(struct xenbus_driver *drv)
 {
+       down(&xenbus_lock);
        driver_unregister(&drv->driver);
+       up(&xenbus_lock);
 }
 
 struct xb_find_info
@@ -203,20 +213,16 @@
        char **dir;
        unsigned int i, dir_n;
 
-       down(&xenbus_lock);
        dir = xenbus_directory(path, "", &dir_n);
-       if (IS_ERR(dir)) {
-               err = PTR_ERR(dir);
-               goto unlock;
-       }
+       if (IS_ERR(dir))
+               return PTR_ERR(dir);
+
        for (i = 0; i < dir_n; i++) {
                err = xenbus_probe_device_type(path, dir[i]);
                if (err)
                        break;
        }
        kfree(dir);
-unlock:
-       up(&xenbus_lock);
        return err;
 }
 
@@ -292,10 +298,10 @@
                return err;
        }
 
+       down(&xenbus_lock);
        /* Enumerate devices in xenstore. */
        xenbus_probe_devices("device");
-
-       down(&xenbus_lock);
+       /* Watch for changes. */
        register_xenbus_watch(&dev_watch);
        up(&xenbus_lock);
        return 0;

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Fix locking: probe can be called from several places, so ensure, Xen patchbot -unstable <=