[PATCH 03/05] PM: Runtime PM v13 - add debug printouts

Magnus Damm
2009-08-07T07:33:42Z

From: Magnus Damm <damm@igel.co.jp>

This patch adds dev_dbg() printouts to the Runtime PM
code. Just add a #define DEBUG at the top of the file
to get suspend and resume printouts. Also add a missing
newline to the pm_runtime_enable() printout while at it.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

Can this patch be rolled into the main Runtime PM patch?

Changes for v11->v13:
- solved conflicts introduced by v11->v13 update

drivers/base/power/runtime.c | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)

--- 0009/drivers/base/power/runtime.c
+++ work/drivers/base/power/runtime.c 2009-08-07 13:55:20.000000000 +0900
@@ -125,13 +125,19 @@ int __pm_runtime_suspend(struct device *
bool notify = false;
int retval = 0;

+ dev_dbg(dev, "__pm_runtime_suspend() %d!\n", from_wq);
repeat:
- if (dev->power.runtime_error)
- return -EINVAL;
+ if (dev->power.runtime_error) {
+ retval = -EINVAL;
+ goto out;
+ }

/* Pending resume requests take precedence over us. */
- if (dev->power.request_pending && dev->power.request == RPM_REQ_RESUME)
- return -EAGAIN;
+ if (dev->power.request_pending
+ && dev->power.request == RPM_REQ_RESUME) {
+ retval = -EAGAIN;
+ goto out;
+ }

/* Other scheduled or pending requests need to be canceled. */
pm_runtime_cancel_pending(dev);
@@ -145,13 +151,15 @@ int __pm_runtime_suspend(struct device *
else if (!pm_children_suspended(dev))
retval = -EBUSY;
if (retval)
- return retval;
+ goto out;

if (dev->power.runtime_status == RPM_SUSPENDING) {
DEFINE_WAIT(wait);

- if (from_wq)
- return -EINPROGRESS;
+ if (from_wq) {
+ retval = -EINPROGRESS;
+ goto out;
+ }

/* Wait for the other suspend running in parallel with us. */
for (;;) {
@@ -200,7 +208,8 @@ int __pm_runtime_suspend(struct device *
if (dev->power.deferred_resume) {
dev->power.deferred_resume = false;
__pm_runtime_resume(dev, false);
- return -EAGAIN;
+ retval = -EAGAIN;
+ goto out;
}

if (notify)
@@ -213,6 +222,8 @@ int __pm_runtime_suspend(struct device *

spin_lock_irq(&dev->power.lock);
}
+ out:
+ dev_dbg(dev, "__pm_runtime_suspend() returns %d!\n", retval);

return retval;
}
@@ -252,6 +263,7 @@ int __pm_runtime_resume(struct device *d
struct device *parent = NULL;
int retval = 0;

+ dev_dbg(dev, "__pm_runtime_resume() %d!\n", from_wq);
repeat:
if (dev->power.runtime_error) {
retval = -EINVAL;
@@ -358,6 +370,8 @@ int __pm_runtime_resume(struct device *d
spin_lock_irq(&dev->power.lock);
}

+ dev_dbg(dev, "__pm_runtime_resume() returns %d!\n", retval);
+
return retval;
}

@@ -795,7 +809,7 @@ void pm_runtime_enable(struct device *de
if (dev->power.disable_depth > 0)
dev->power.disable_depth--;
else
- dev_warn(dev, "Unbalanced %s!", __func__);
+ dev_warn(dev, "Unbalanced %s!\n", __func__);

spin_unlock_irqrestore(&dev->power.lock, flags);
}