]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
Driver core: Add BUS_NOTIFY_BIND_DRIVER
authorMagnus Damm <damm@opensource.se>
Fri, 23 Jul 2010 10:56:18 +0000 (19:56 +0900)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 5 Aug 2010 20:53:35 +0000 (13:53 -0700)
Add BUS_NOTIFY_BIND_DRIVER as a bus notifier event.

For driver binding/unbinding we with this in
place have the following bus notifier events:
 - BUS_NOTIFY_BIND_DRIVER - before ->probe()
 - BUS_NOTIFY_BOUND_DRIVER - after ->probe()
 - BUS_NOTIFY_UNBIND_DRIVER - before ->remove()
 - BUS_NOTIFY_UNBOUND_DRIVER - after ->remove()

The event BUS_NOTIFY_BIND_DRIVER allows bus code
to be notified that ->probe() is about to be called.

Useful for bus code that needs to setup hardware before
the driver gets to run. With this in place platform
drivers can be loaded and unloaded as modules and the
new BIND event allows bus code to control for instance
device clocks that must be enabled before the driver
can be executed.

Without this patch there is no way for the bus code to
get notified that a modular driver is about to be probed.

Signed-off-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/dd.c
include/linux/device.h

index 503c2620bbcc995cebe5f455405ee2f436cf9241..da57ee9d63febb2d525883a84a137962ca3a07c0 100644 (file)
@@ -51,6 +51,10 @@ static int driver_sysfs_add(struct device *dev)
 {
        int ret;
 
+       if (dev->bus)
+               blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
+                                            BUS_NOTIFY_BIND_DRIVER, dev);
+
        ret = sysfs_create_link(&dev->driver->p->kobj, &dev->kobj,
                          kobject_name(&dev->kobj));
        if (ret == 0) {
index ddffdf7da393aec8d3147e9889772a2e1ffd546f..0ca24e93304fc1dcc3f410950dbba5562337563a 100644 (file)
@@ -109,10 +109,12 @@ extern int bus_unregister_notifier(struct bus_type *bus,
  */
 #define BUS_NOTIFY_ADD_DEVICE          0x00000001 /* device added */
 #define BUS_NOTIFY_DEL_DEVICE          0x00000002 /* device removed */
-#define BUS_NOTIFY_BOUND_DRIVER                0x00000003 /* driver bound to device */
-#define BUS_NOTIFY_UNBIND_DRIVER       0x00000004 /* driver about to be
+#define BUS_NOTIFY_BIND_DRIVER         0x00000003 /* driver about to be
+                                                     bound */
+#define BUS_NOTIFY_BOUND_DRIVER                0x00000004 /* driver bound to device */
+#define BUS_NOTIFY_UNBIND_DRIVER       0x00000005 /* driver about to be
                                                      unbound */
-#define BUS_NOTIFY_UNBOUND_DRIVER      0x00000005 /* driver is unbound
+#define BUS_NOTIFY_UNBOUND_DRIVER      0x00000006 /* driver is unbound
                                                      from the device */
 
 extern struct kset *bus_get_kset(struct bus_type *bus);