Skip to contentSkip to conversation

I2C: runtime: Fix checks which make legacy suspend to never get called

PATCH Applied Rajendra Nayak 5 participants 5 messages Sep 27, 2010 – Sep 29, 2010 2 messages not in the archive

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

PATCH 1/1 I2C: runtime: Fix checks which make legacy suspend to never get called

For devices which are not adapted to runtime PM a call to pm_runtime_suspended always returns true.

Hence the pm_runtime_suspended checks below prevent legacy suspend from getting called.

So do a pm_runtime_suspended check only for devices with a dev_pm_ops populated (which hence do not rely on the legacy suspend)

Cc Rafael J. Wysocki <[email protected]>
Cc Ben Dooks <[email protected]>
Cc Mark Brown <broonie-yzvPICuk2AATkU/[email protected]>
Cc Jean Delvare <[email protected]>
Cc Kevin Hilman <[email protected]>
---
 drivers/i2c/i2c-core.c |   44 ++++++++++++++++++++++++--------------------
 1 files changed, 24 insertions(+), 20 deletions(-)
drivers/i2c/i2c-core.c +24 -20
index 6649176..712086f 100644
@@ -197,11 +197,12 @@ static int i2c_device_pm_suspend(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm_runtime_suspended(dev))
-		return 0;
-
-	if (pm)
-		return pm->suspend ? pm->suspend(dev) : 0;
+	if (pm) {
+		if (pm_runtime_suspended(dev))
+			return 0;
+		else
+			return pm->suspend ? pm->suspend(dev) : 0;
+	}
 
 	return i2c_legacy_suspend(dev, PMSG_SUSPEND);
 }
@@ -229,11 +230,12 @@ static int i2c_device_pm_freeze(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm_runtime_suspended(dev))
-		return 0;
-
-	if (pm)
-		return pm->freeze ? pm->freeze(dev) : 0;
+	if (pm) {
+		if (pm_runtime_suspended(dev))
+			return 0;
+		else
+			return pm->freeze ? pm->freeze(dev) : 0;
+	}
 
 	return i2c_legacy_suspend(dev, PMSG_FREEZE);
 }
@@ -242,11 +244,12 @@ static int i2c_device_pm_thaw(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm_runtime_suspended(dev))
-		return 0;
-
-	if (pm)
-		return pm->thaw ? pm->thaw(dev) : 0;
+	if (pm) {
+		if (pm_runtime_suspended(dev))
+			return 0;
+		else
+			return pm->thaw ? pm->thaw(dev) : 0;
+	}
 
 	return i2c_legacy_resume(dev);
 }
@@ -255,11 +258,12 @@ static int i2c_device_pm_poweroff(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm_runtime_suspended(dev))
-		return 0;
-
-	if (pm)
-		return pm->poweroff ? pm->poweroff(dev) : 0;
+	if (pm) {
+		if (pm_runtime_suspended(dev))
+			return 0;
+		else
+			return pm->poweroff ? pm->poweroff(dev) : 0;
+	}
 
 	return i2c_legacy_suspend(dev, PMSG_HIBERNATE);
 }
Signature · 1 line
1.7.0.4

A message that is not in the archive (sent off-list or not yet received): 1285602360-21180-1-git-send-email-rnayak-l0cyMroinI0@public.gmane.org

#2 lore raw
Quoted 9 lines · Rajendra Nayak

For devices which are not adapted to runtime PM a call to pm_runtime_suspended always returns true.

Hence the pm_runtime_suspended checks below prevent legacy suspend from getting called.

So do a pm_runtime_suspended check only for devices with a dev_pm_ops populated (which hence do not rely on the legacy suspend)

Makes sense.

Quoted 2 lines
Cc Rafael J. Wysocki <[email protected]>
Quoted 85 lines
Cc Ben Dooks <[email protected]>
Cc Mark Brown <broonie-yzvPICuk2AATkU/[email protected]>
Cc Jean Delvare <[email protected]>
Cc Kevin Hilman <[email protected]>
---
 drivers/i2c/i2c-core.c |   44 ++++++++++++++++++++++++--------------------
 1 files changed, 24 insertions(+), 20 deletions(-)
drivers/i2c/i2c-core.c +24 -20
index 6649176..712086f 100644
@@ -197,11 +197,12 @@ static int i2c_device_pm_suspend(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm_runtime_suspended(dev))
-		return 0;
-
-	if (pm)
-		return pm->suspend ? pm->suspend(dev) : 0;
+	if (pm) {
+		if (pm_runtime_suspended(dev))
+			return 0;
+		else
+			return pm->suspend ? pm->suspend(dev) : 0;
+	}
 
 	return i2c_legacy_suspend(dev, PMSG_SUSPEND);
 }
@@ -229,11 +230,12 @@ static int i2c_device_pm_freeze(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm_runtime_suspended(dev))
-		return 0;
-
-	if (pm)
-		return pm->freeze ? pm->freeze(dev) : 0;
+	if (pm) {
+		if (pm_runtime_suspended(dev))
+			return 0;
+		else
+			return pm->freeze ? pm->freeze(dev) : 0;
+	}
 
 	return i2c_legacy_suspend(dev, PMSG_FREEZE);
 }
@@ -242,11 +244,12 @@ static int i2c_device_pm_thaw(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm_runtime_suspended(dev))
-		return 0;
-
-	if (pm)
-		return pm->thaw ? pm->thaw(dev) : 0;
+	if (pm) {
+		if (pm_runtime_suspended(dev))
+			return 0;
+		else
+			return pm->thaw ? pm->thaw(dev) : 0;
+	}
 
 	return i2c_legacy_resume(dev);
 }
@@ -255,11 +258,12 @@ static int i2c_device_pm_poweroff(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm_runtime_suspended(dev))
-		return 0;
-
-	if (pm)
-		return pm->poweroff ? pm->poweroff(dev) : 0;
+	if (pm) {
+		if (pm_runtime_suspended(dev))
+			return 0;
+		else
+			return pm->poweroff ? pm->poweroff(dev) : 0;
+	}
 
 	return i2c_legacy_suspend(dev, PMSG_HIBERNATE);
 }

A message that is not in the archive (sent off-list or not yet received): [email protected]

Applied
#4 lore raw
Quoted 11 lines · Rafael J. Wysocki
Quoted 9 lines · Rajendra Nayak

For devices which are not adapted to runtime PM a call to pm_runtime_suspended always returns true.

Hence the pm_runtime_suspended checks below prevent legacy suspend from getting called.

So do a pm_runtime_suspended check only for devices with a dev_pm_ops populated (which hence do not rely on the legacy suspend)

Quoted 14 lines

Makes sense.

Quoted 2 lines
Cc Rafael J. Wysocki <[email protected]>
Quoted 7 lines
Cc Ben Dooks <[email protected]>
Cc Mark Brown <broonie-yzvPICuk2AATkU/[email protected]>
Cc Jean Delvare <[email protected]>
Cc Kevin Hilman <[email protected]>
---
 drivers/i2c/i2c-core.c |   44 ++++++++++++++++++++++++--------------------
 1 files changed, 24 insertions(+), 20 deletions(-)

Applied, thanks.

Signature · 1 line
Jean Delvare
Applied
#5 lore raw
In reply to Rafael J. Wysocki
Quoted 11 lines · Rafael J. Wysocki
Quoted 9 lines · Rajendra Nayak

For devices which are not adapted to runtime PM a call to pm_runtime_suspended always returns true.

Hence the pm_runtime_suspended checks below prevent legacy suspend from getting called.

So do a pm_runtime_suspended check only for devices with a dev_pm_ops populated (which hence do not rely on the legacy suspend)

Quoted 14 lines

Makes sense.

Quoted 2 lines
Cc Rafael J. Wysocki <[email protected]>
Quoted 7 lines
Cc Ben Dooks <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jean Delvare <[email protected]>
Cc Kevin Hilman <[email protected]>
---
 drivers/i2c/i2c-core.c |   44 ++++++++++++++++++++++++--------------------
 1 files changed, 24 insertions(+), 20 deletions(-)

Applied, thanks.

Signature · 1 line
Jean Delvare
Acked-by on v1 1/1
#6 lore raw
In reply to Rajendra Nayak
Quoted 9 lines · Rajendra Nayak

For devices which are not adapted to runtime PM a call to pm_runtime_suspended always returns true.

Hence the pm_runtime_suspended checks below prevent legacy suspend from getting called.

So do a pm_runtime_suspended check only for devices with a dev_pm_ops populated (which hence do not rely on the legacy suspend)

Makes sense.

Quoted 2 lines
Cc Rafael J. Wysocki <[email protected]>
Quoted 85 lines
Cc Ben Dooks <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jean Delvare <[email protected]>
Cc Kevin Hilman <[email protected]>
---
 drivers/i2c/i2c-core.c |   44 ++++++++++++++++++++++++--------------------
 1 files changed, 24 insertions(+), 20 deletions(-)
drivers/i2c/i2c-core.c +24 -20
index 6649176..712086f 100644
@@ -197,11 +197,12 @@ static int i2c_device_pm_suspend(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm_runtime_suspended(dev))
-		return 0;
-
-	if (pm)
-		return pm->suspend ? pm->suspend(dev) : 0;
+	if (pm) {
+		if (pm_runtime_suspended(dev))
+			return 0;
+		else
+			return pm->suspend ? pm->suspend(dev) : 0;
+	}
 
 	return i2c_legacy_suspend(dev, PMSG_SUSPEND);
 }
@@ -229,11 +230,12 @@ static int i2c_device_pm_freeze(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm_runtime_suspended(dev))
-		return 0;
-
-	if (pm)
-		return pm->freeze ? pm->freeze(dev) : 0;
+	if (pm) {
+		if (pm_runtime_suspended(dev))
+			return 0;
+		else
+			return pm->freeze ? pm->freeze(dev) : 0;
+	}
 
 	return i2c_legacy_suspend(dev, PMSG_FREEZE);
 }
@@ -242,11 +244,12 @@ static int i2c_device_pm_thaw(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm_runtime_suspended(dev))
-		return 0;
-
-	if (pm)
-		return pm->thaw ? pm->thaw(dev) : 0;
+	if (pm) {
+		if (pm_runtime_suspended(dev))
+			return 0;
+		else
+			return pm->thaw ? pm->thaw(dev) : 0;
+	}
 
 	return i2c_legacy_resume(dev);
 }
@@ -255,11 +258,12 @@ static int i2c_device_pm_poweroff(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm_runtime_suspended(dev))
-		return 0;
-
-	if (pm)
-		return pm->poweroff ? pm->poweroff(dev) : 0;
+	if (pm) {
+		if (pm_runtime_suspended(dev))
+			return 0;
+		else
+			return pm->poweroff ? pm->poweroff(dev) : 0;
+	}
 
 	return i2c_legacy_suspend(dev, PMSG_HIBERNATE);
 }