Skip to contentSkip to conversation

PM: Avoid false-positive warnings in dev_pm_domain_set()

PATCH In review Andy Shevchenko 1 participant 2 messages Feb 1, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM: Avoid false-positive warnings in dev_pm_domain_set()

From: "Rafael J. Wysocki" <[email protected]>

There is a WARN_ON() in dev_pm_domain_set() that triggers on attempts to set the pm_domain pointer for devices with a driver bound.

However, that WARN_ON() triggers on attempts to clear the pointer too and the test it uses is based on checking the device's p->knode_driver pointer which still is set when the device bus type's/driver's ->remove callback has been executed. This leads to false-positive warnings when bus type code calls dev_pm_domain_set() to clear the pm_domain pointer after invoking the driver's ->remove() callback.

To avoid those false-positives, make dev_pm_domain_set() check if the pointer passed to it is NULL and skip the warning in that case.

Fixes 989561de9b51 (PM / Domains: add setter for dev.pm_domain)
---
 drivers/base/power/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/power/common.c +1 -1
index 93ed14c..f6a9ad5 100644
@@ -146,7 +146,7 @@ void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd)
 	if (dev->pm_domain == pd)
 		return;
 
-	WARN(device_is_bound(dev),
+	WARN(pd && device_is_bound(dev),
 	     "PM domains can only be changed for unbound devices\n");
 	dev->pm_domain = pd;
 	device_pm_check_callbacks(dev);
Signature · 1 line
2.7.0
#1 lore raw
Quoted 13 lines · Andy Shevchenko

From: "Rafael J. Wysocki" <[email protected]>

There is a WARN_ON() in dev_pm_domain_set() that triggers on attempts to set the pm_domain pointer for devices with a driver bound.

However, that WARN_ON() triggers on attempts to clear the pointer too and the test it uses is based on checking the device's p->knode_driver pointer which still is set when the device bus type's/driver's ->remove callback has been executed.  This leads to false-positive warnings when bus type code calls dev_pm_domain_set() to clear the pm_domain pointer after invoking the driver's ->remove() callback.

Quoted 7 lines

To avoid those false-positives, make dev_pm_domain_set() check if the pointer passed to it is NULL and skip the warning in that case.

Fixes 989561de9b51 (PM / Domains: add setter for dev.pm_domain)

Oops, it is a wrong one, should be previous.

Btw, this one has been tested and went fine!

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy