Merge branches 'x86-cleanups-for-linus' and 'x86-cpufeature-for-linus' of git://git...
[deliverable/linux.git] / drivers / base / dd.c
index dcb8a6e4869249e4b26b405a9348f02113809ba6..e3bbed8a617c257373a1fa2d75318d9ff930601a 100644 (file)
@@ -85,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);
@@ -283,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 */
@@ -356,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;
 }
@@ -406,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);
@@ -487,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.030394 seconds and 5 git commands to generate.