]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Driver core: remove unneeded completion from driver release path
authorGreg Kroah-Hartman <gregkh@suse.de>
Tue, 9 Apr 2002 19:14:34 +0000 (12:14 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 27 Apr 2007 17:57:29 +0000 (10:57 -0700)
The completion in the driver release path is due to ancient history in
the _very_ early 2.5 days when we were not tracking the module reference
count of attributes.  It is not needed at all and can be removed.

Note, we now have an empty release function for the driver structure.
This is due to the fact that drivers are statically allocated in the
system at this point in time, something which I want to change in the
future.  But remember, drivers are really code, which is reference
counted by the module, unlike devices, which are data and _must_ be
reference counted properly in order to work correctly.

Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/bus.c
drivers/base/driver.c
include/linux/device.h

index 20b6dc8706fa6764197bd07930ea624e90dbbba1..1a5a350eca15393a92b3f5c8e1c8eca28c25a741 100644 (file)
@@ -63,8 +63,19 @@ static struct sysfs_ops driver_sysfs_ops = {
 
 static void driver_release(struct kobject * kobj)
 {
-       struct device_driver * drv = to_driver(kobj);
-       complete(&drv->unloaded);
+       /*
+        * Yes this is an empty release function, it is this way because struct
+        * device is always a static object, not a dynamic one.  Yes, this is
+        * not nice and bad, but remember, drivers are code, reference counted
+        * by the module count, not a device, which is really data.  And yes,
+        * in the future I do want to have all drivers be created dynamically,
+        * and am working toward that goal, but it will take a bit longer...
+        *
+        * But do not let this example give _anyone_ the idea that they can
+        * create a release function without any code in it at all, to do that
+        * is almost always wrong.  If you have any questions about this,
+        * please send an email to <greg@kroah.com>
+        */
 }
 
 static struct kobj_type ktype_driver = {
index 082bfded38544b0fc055861a79112446ae6199c9..eb11475293ed614ea381589296db607381099cc2 100644 (file)
@@ -149,10 +149,6 @@ void put_driver(struct device_driver * drv)
  *     We pass off most of the work to the bus_add_driver() call,
  *     since most of the things we have to do deal with the bus
  *     structures.
- *
- *     The one interesting aspect is that we setup @drv->unloaded
- *     as a completion that gets complete when the driver reference
- *     count reaches 0.
  */
 int driver_register(struct device_driver * drv)
 {
@@ -162,35 +158,19 @@ int driver_register(struct device_driver * drv)
                printk(KERN_WARNING "Driver '%s' needs updating - please use bus_type methods\n", drv->name);
        }
        klist_init(&drv->klist_devices, NULL, NULL);
-       init_completion(&drv->unloaded);
        return bus_add_driver(drv);
 }
 
-
 /**
  *     driver_unregister - remove driver from system.
  *     @drv:   driver.
  *
  *     Again, we pass off most of the work to the bus-level call.
- *
- *     Though, once that is done, we wait until @drv->unloaded is completed.
- *     This will block until the driver refcount reaches 0, and it is
- *     released. Only modular drivers will call this function, and we
- *     have to guarantee that it won't complete, letting the driver
- *     unload until all references are gone.
  */
 
 void driver_unregister(struct device_driver * drv)
 {
        bus_remove_driver(drv);
-       /*
-        * If the driver is a module, we are probably in
-        * the module unload path, and we want to wait
-        * for everything to unload before we can actually
-        * finish the unload.
-        */
-       if (drv->owner)
-               wait_for_completion(&drv->unloaded);
 }
 
 /**
index eb1fff0b1d2ac30df4d74a7b2513188adca66d06..c9dc458e8e507afffe4337e4fd20d922ce7b7494 100644 (file)
@@ -126,7 +126,6 @@ struct device_driver {
        const char              * name;
        struct bus_type         * bus;
 
-       struct completion       unloaded;
        struct kobject          kobj;
        struct klist            klist_devices;
        struct klist_node       knode_bus;