Skip to contentSkip to conversation

PM / Domains: Only check for errors when calling dev_pm_get_subsys_data

PATCH Applied Heiko Stübner 2 participants 3 messages Aug 5, 2012

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

PATCH 1/1 PM / Domains: Only check for errors when calling dev_pm_get_subsys_data

Commit 1d5fcfec22 (PM / Domains: Add device domain data reference counter) added a check for the return value of dev_pm_get_subsys_data.

But this function does not only return error codes but also "1" when a new object has been created.

So, change the check to only catch real errors.

---
against 3.6-rc1

 drivers/base/power/domain.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/base/power/domain.c +1 -1
index ba3487c..5959fcb 100644
@@ -1323,7 +1323,7 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
 		}
 
 	ret = dev_pm_get_subsys_data(dev);
-	if (ret)
+	if (ret < 0)
 		goto out;
 
 	genpd->device_count++;
Signature · 1 line
1.7.2.3
#1 lore raw
Quoted 9 lines · Heiko Stübner

Commit 1d5fcfec22 (PM / Domains: Add device domain data reference counter) added a check for the return value of dev_pm_get_subsys_data.

But this function does not only return error codes but also "1" when a new object has been created.

So, change the check to only catch real errors.

Good catch!

Applied to the linux-next branch of the linux-pm.git tree. I'm going to push it as a fix for v3.6.

However, there's one more analogous fix necessary, for which I'm going to apply the appended patch.

Thanks,
Rafael

---
From: Rafael J. Wysocki <[email protected]>
Subject: PM / Domains: Fix one more dev_pm_get_subsys_data() return value check

The check agains the return value of dev_pm_get_subsys_data() in pm_genpd_add_callbacks() should be modified so that non-negative values are not regarded as errors, because dev_pm_get_subsys_data() returns 1 if it successfully creates a new object.

---
 drivers/base/power/domain.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/power/domain.c +1 -1
Index: linux/drivers/base/power/domain.c
===================================================================
@@ -1691,7 +1691,7 @@ int pm_genpd_add_callbacks(struct device
 	device_pm_lock();
 
 	ret = dev_pm_get_subsys_data(dev);
-	if (ret)
+	if (ret < 0)
 		goto out;
 
 	spin_lock_irq(&dev->power.lock);
#2 lore raw

Am Sonntag, 5. August 2012, 23:13:46 schrieb Rafael J. Wysocki:

Quoted 12 lines · Heiko Stübner
Quoted 9 lines

Commit 1d5fcfec22 (PM / Domains: Add device domain data reference counter) added a check for the return value of dev_pm_get_subsys_data.

But this function does not only return error codes but also "1" when a new object has been created.

So, change the check to only catch real errors.

Good catch!

it bit me while moving to 3.6-rc1 with my machine support - suddenly my usbphy didn't turn on again :-)

Quoted 5 lines

Applied to the linux-next branch of the linux-pm.git tree. I'm going to push it as a fix for v3.6.

However, there's one more analogous fix necessary, for which I'm going to apply the appended patch.

Sorry :-) - I did only check the rest of 1d5fcfec22 for more of this, but not the whole domain.c. The second occurence seems to have been introduced by 62d4490294.

Heiko

Quoted 32 lines

Thanks,
Rafael

---
From: Rafael J. Wysocki <[email protected]>
Subject: PM / Domains: Fix one more dev_pm_get_subsys_data() return value check

The check agains the return value of dev_pm_get_subsys_data() in pm_genpd_add_callbacks() should be modified so that non-negative values are not regarded as errors, because dev_pm_get_subsys_data() returns 1 if it successfully creates a new object.

---
 drivers/base/power/domain.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux/drivers/base/power/domain.c
===================================================================

drivers/base/power/domain.c +1 -1
@@ -1691,7 +1691,7 @@ int pm_genpd_add_callbacks(struct device
 	device_pm_lock();
 
 	ret = dev_pm_get_subsys_data(dev);
-	if (ret)
+	if (ret < 0)
 		goto out;
 
 	spin_lock_irq(&dev->power.lock);