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 = {
* 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)
{
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);
}
/**