]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/base/dd.c
Merge branch 'devel' of git://git.kernel.org/pub/scm/linux/kernel/git/ycmiao/pxa...
[linux-2.6-omap-h63xx.git] / drivers / base / dd.c
index 6fdaf76f033fcc4704b879189db3828884b56544..1352312391032fcda76f672c5b43a76e5c6df6f0 100644 (file)
  */
 
 #include <linux/device.h>
+#include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/kthread.h>
 #include <linux/wait.h>
+#include <linux/async.h>
 
 #include "base.h"
 #include "power/power.h"
@@ -28,7 +30,7 @@
 
 static void driver_bound(struct device *dev)
 {
-       if (klist_node_attached(&dev->p->knode_driver)) {
+       if (klist_node_attached(&dev->knode_driver)) {
                printk(KERN_WARNING "%s: device %s already bound\n",
                        __func__, kobject_name(&dev->kobj));
                return;
@@ -41,7 +43,7 @@ static void driver_bound(struct device *dev)
                blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
                                             BUS_NOTIFY_BOUND_DRIVER, dev);
 
-       klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices);
+       klist_add_tail(&dev->knode_driver, &dev->driver->p->klist_devices);
 }
 
 static int driver_sysfs_add(struct device *dev)
@@ -167,6 +169,21 @@ int driver_probe_done(void)
        return 0;
 }
 
+/**
+ * wait_for_device_probe
+ * Wait for device probing to be completed.
+ *
+ * Note: this function polls at 100 msec intervals.
+ */
+int wait_for_device_probe(void)
+{
+       /* wait for the known devices to complete their probing */
+       while (driver_probe_done() != 0)
+               msleep(100);
+       async_synchronize_full();
+       return 0;
+}
+
 /**
  * driver_probe_device - attempt to bind device & driver together
  * @drv: driver to bind a device to
@@ -310,7 +327,7 @@ static void __device_release_driver(struct device *dev)
                        drv->remove(dev);
                devres_release_all(dev);
                dev->driver = NULL;
-               klist_remove(&dev->p->knode_driver);
+               klist_remove(&dev->knode_driver);
        }
 }
 
@@ -340,7 +357,6 @@ EXPORT_SYMBOL_GPL(device_release_driver);
  */
 void driver_detach(struct device_driver *drv)
 {
-       struct device_private *dev_prv;
        struct device *dev;
 
        for (;;) {
@@ -349,10 +365,8 @@ void driver_detach(struct device_driver *drv)
                        spin_unlock(&drv->p->klist_devices.k_lock);
                        break;
                }
-               dev_prv = list_entry(drv->p->klist_devices.k_list.prev,
-                                    struct device_private,
-                                    knode_driver.n_node);
-               dev = dev_prv->device;
+               dev = list_entry(drv->p->klist_devices.k_list.prev,
+                               struct device, knode_driver.n_node);
                get_device(dev);
                spin_unlock(&drv->p->klist_devices.k_lock);