Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[deliverable/linux.git] / drivers / base / dd.c
index 4b01ab3d2c249328c810aaa03aec450d7f8d2822..e3bbed8a617c257373a1fa2d75318d9ff930601a 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/wait.h>
 #include <linux/async.h>
 #include <linux/pm_runtime.h>
-#include <scsi/scsi_scan.h>
 
 #include "base.h"
 #include "power/power.h"
@@ -86,8 +85,20 @@ static void deferred_probe_work_func(struct work_struct *work)
                 * manipulate the deferred list
                 */
                mutex_unlock(&deferred_probe_mutex);
+
+               /*
+                * Force the device to the end of the dpm_list since
+                * the PM code assumes that the order we add things to
+                * the list is a good order for suspend but deferred
+                * probe makes that very unsafe.
+                */
+               device_pm_lock();
+               device_pm_move_last(dev);
+               device_pm_unlock();
+
                dev_dbg(dev, "Retrying from deferred list\n");
                bus_probe_device(dev);
+
                mutex_lock(&deferred_probe_mutex);
 
                put_device(dev);
@@ -284,6 +295,7 @@ probe_failed:
        devres_release_all(dev);
        driver_sysfs_remove(dev);
        dev->driver = NULL;
+       dev_set_drvdata(dev, NULL);
 
        if (ret == -EPROBE_DEFER) {
                /* Driver requested deferred probing */
@@ -333,7 +345,6 @@ void wait_for_device_probe(void)
        /* wait for the known devices to complete their probing */
        wait_event(probe_waitqueue, atomic_read(&probe_count) == 0);
        async_synchronize_full();
-       scsi_complete_async_scans();
 }
 EXPORT_SYMBOL_GPL(wait_for_device_probe);
 
@@ -358,10 +369,9 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
        pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
                 drv->bus->name, __func__, dev_name(dev), drv->name);
 
-       pm_runtime_get_noresume(dev);
        pm_runtime_barrier(dev);
        ret = really_probe(dev, drv);
-       pm_runtime_put_sync(dev);
+       pm_runtime_idle(dev);
 
        return ret;
 }
@@ -408,9 +418,8 @@ int device_attach(struct device *dev)
                        ret = 0;
                }
        } else {
-               pm_runtime_get_noresume(dev);
                ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
-               pm_runtime_put_sync(dev);
+               pm_runtime_idle(dev);
        }
 out_unlock:
        device_unlock(dev);
@@ -489,6 +498,7 @@ static void __device_release_driver(struct device *dev)
                        drv->remove(dev);
                devres_release_all(dev);
                dev->driver = NULL;
+               dev_set_drvdata(dev, NULL);
                klist_remove(&dev->p->knode_driver);
                if (dev->bus)
                        blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
This page took 0.027079 seconds and 5 git commands to generate.