drivers/rtc/rtc-pxa.c: fix alarm not match issue
[linux-3.10.git] / drivers / base / dd.c
index dcb8a6e..6563101 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/wait.h>
 #include <linux/async.h>
 #include <linux/pm_runtime.h>
+#include <linux/pinctrl/devinfo.h>
 
 #include "base.h"
 #include "power/power.h"
@@ -85,8 +86,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);
@@ -257,6 +270,12 @@ static int really_probe(struct device *dev, struct device_driver *drv)
        WARN_ON(!list_empty(&dev->devres_head));
 
        dev->driver = drv;
+
+       /* If using pinctrl, bind pins now before probing */
+       ret = pinctrl_bind_pins(dev);
+       if (ret)
+               goto probe_failed;
+
        if (driver_sysfs_add(dev)) {
                printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n",
                        __func__, dev_name(dev));
@@ -283,6 +302,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 +376,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 +425,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 +505,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,