The below patch makes sure that dev->parent supports runtime PM before accessing its PM fields. Though the code does this check at a later point in time, doing it earlier can optimize the code flow. Regards, Nithish Mahalingam >From 2e7fe2ea2737b8f70da20c8ec77235f8548d1331 Mon Sep 17 00:00:00 2001 From: Nithish Mahalingam <nithish.mahalingam@xxxxxxxxx> Date: Thu, 3 Dec 2009 13:27:02 +0530 Subject: [PATCH] Adding explicit check to make sure dev->parent supports runtime PM before accessing its PM fields. This patch adds explicit checks to make sure dev->parent supports runtime PM before accessing any of its runtime PM fields. modified: drivers/base/power/runtime.c Signed-off-by: Nithish Mahalingam <nithish.mahalingam@xxxxxxxxx> --- drivers/base/power/runtime.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 846d89e..87ac2d6 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -209,7 +209,7 @@ int __pm_runtime_suspend(struct device *dev, bool from_wq) } else { dev->power.runtime_status = RPM_SUSPENDED; - if (dev->parent) { + if (dev->parent && !dev->parent->power.disable_depth) { parent = dev->parent; atomic_add_unless(&parent->power.child_count, -1, 0); } @@ -322,7 +322,7 @@ int __pm_runtime_resume(struct device *dev, bool from_wq) goto repeat; } - if (!parent && dev->parent) { + if (dev->parent && !dev->parent->power.disable_depth) { /* * Increment the parent's resume counter and resume it if * necessary. @@ -334,11 +334,10 @@ int __pm_runtime_resume(struct device *dev, bool from_wq) spin_lock(&parent->power.lock); /* - * We can resume if the parent's run-time PM is disabled or it - * is set to ignore children. + * We can resume if the parent's run-time PM is set to + * ignore children. */ - if (!parent->power.disable_depth - && !parent->power.ignore_children) { + if (!parent->power.ignore_children) { __pm_runtime_resume(parent, false); if (parent->power.runtime_status != RPM_ACTIVE) retval = -EBUSY; @@ -749,7 +748,9 @@ EXPORT_SYMBOL_GPL(__pm_runtime_put); */ int __pm_runtime_set_status(struct device *dev, unsigned int status) { - struct device *parent = dev->parent; + struct device *parent = dev->parent ? + (dev->parent->power.disable_depth ? NULL : dev->parent) : + NULL; unsigned long flags; bool notify_parent = false; int error = 0; @@ -784,8 +785,7 @@ int __pm_runtime_set_status(struct device *dev, unsigned int status) * not active, has run-time PM enabled and the * 'power.ignore_children' flag unset. */ - if (!parent->power.disable_depth - && !parent->power.ignore_children + if (!parent->power.ignore_children && parent->power.runtime_status != RPM_ACTIVE) { error = -EBUSY; } else { -- 1.6.5.2 _______________________________________________ linux-pm mailing list linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linux-foundation.org/mailman/listinfo/linux-pm