]> rtime.felk.cvut.cz Git - linux-imx.git/blobdiff - drivers/base/power/runtime.c
PM / Runtime: Rework the "runtime idle" helper routine
[linux-imx.git] / drivers / base / power / runtime.c
index ef13ad08afb2cf845340bb28463ad3df63e5b04b..268a35097578d94f78f4baef4d9cc8b3fa1c31cd 100644 (file)
@@ -293,11 +293,8 @@ static int rpm_idle(struct device *dev, int rpmflags)
        /* Pending requests need to be canceled. */
        dev->power.request = RPM_REQ_NONE;
 
-       if (dev->power.no_callbacks) {
-               /* Assume ->runtime_idle() callback would have suspended. */
-               retval = rpm_suspend(dev, rpmflags);
+       if (dev->power.no_callbacks)
                goto out;
-       }
 
        /* Carry out an asynchronous or a synchronous idle notification. */
        if (rpmflags & RPM_ASYNC) {
@@ -306,7 +303,8 @@ static int rpm_idle(struct device *dev, int rpmflags)
                        dev->power.request_pending = true;
                        queue_work(pm_wq, &dev->power.work);
                }
-               goto out;
+               trace_rpm_return_int(dev, _THIS_IP_, 0);
+               return 0;
        }
 
        dev->power.idle_notification = true;
@@ -326,14 +324,14 @@ static int rpm_idle(struct device *dev, int rpmflags)
                callback = dev->driver->pm->runtime_idle;
 
        if (callback)
-               __rpm_callback(callback, dev);
+               retval = __rpm_callback(callback, dev);
 
        dev->power.idle_notification = false;
        wake_up_all(&dev->power.wait_queue);
 
  out:
        trace_rpm_return_int(dev, _THIS_IP_, retval);
-       return retval;
+       return retval ? retval : rpm_suspend(dev, rpmflags);
 }
 
 /**