All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Ben Dooks <ben-linux@fluff.org>,
	Jean Delvare <khali@linux-fr.org>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	Alan Stern <stern@rowland.harvard.edu>
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pm@lists.linux-foundation.org,
	patches@opensource.wolfsonmicro.com,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH 2/2] i2c: Factor out runtime suspend checks from PM operations
Date: Mon, 20 Dec 2010 14:33:13 +0000	[thread overview]
Message-ID: <1292855593-30608-2-git-send-email-broonie@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1292855593-30608-1-git-send-email-broonie@opensource.wolfsonmicro.com>

When devices use dev_pm_ops the I2C API is implementing standard functionality
for integration with runtime PM and for checking for the presence of a per
device op. The PM core provides pm_generic_ functions implementing this
behaviour - use them to reduce coupling with future PM updates.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/i2c/i2c-core.c |   57 ++++++++++++++++--------------------------------
 1 files changed, 19 insertions(+), 38 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 6b4cc56..4478557 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -196,69 +196,50 @@ static int i2c_device_pm_suspend(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm) {
-		if (pm_runtime_suspended(dev))
-			return 0;
-		else
-			return pm->suspend ? pm->suspend(dev) : 0;
-	}
-
-	return i2c_legacy_suspend(dev, PMSG_SUSPEND);
+	if (pm)
+		return pm_generic_suspend(dev);
+	else
+		return i2c_legacy_suspend(dev, PMSG_SUSPEND);
 }
 
 static int i2c_device_pm_resume(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
-	int ret;
 
 	if (pm)
-		ret = pm->resume ? pm->resume(dev) : 0;
+		return pm_generic_resume(dev);
 	else
-		ret = i2c_legacy_resume(dev);
-
-	return ret;
+		return i2c_legacy_resume(dev);
 }
 
 static int i2c_device_pm_freeze(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm) {
-		if (pm_runtime_suspended(dev))
-			return 0;
-		else
-			return pm->freeze ? pm->freeze(dev) : 0;
-	}
-
-	return i2c_legacy_suspend(dev, PMSG_FREEZE);
+	if (pm)
+		return pm_generic_freeze(dev);
+	else
+		return i2c_legacy_suspend(dev, PMSG_FREEZE);
 }
 
 static int i2c_device_pm_thaw(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm) {
-		if (pm_runtime_suspended(dev))
-			return 0;
-		else
-			return pm->thaw ? pm->thaw(dev) : 0;
-	}
-
-	return i2c_legacy_resume(dev);
+	if (pm)
+		return pm_generic_thaw(dev);
+	else
+		return i2c_legacy_resume(dev);
 }
 
 static int i2c_device_pm_poweroff(struct device *dev)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 
-	if (pm) {
-		if (pm_runtime_suspended(dev))
-			return 0;
-		else
-			return pm->poweroff ? pm->poweroff(dev) : 0;
-	}
-
-	return i2c_legacy_suspend(dev, PMSG_HIBERNATE);
+	if (pm)
+		return pm_generic_poweroff(dev);
+	else
+		return i2c_legacy_suspend(dev, PMSG_HIBERNATE);
 }
 
 static int i2c_device_pm_restore(struct device *dev)
@@ -267,7 +248,7 @@ static int i2c_device_pm_restore(struct device *dev)
 	int ret;
 
 	if (pm)
-		ret = pm->restore ? pm->restore(dev) : 0;
+		ret = pm_generic_restore(dev);
 	else
 		ret = i2c_legacy_resume(dev);
 
-- 
1.7.2.3


  parent reply	other threads:[~2010-12-20 14:33 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-20 14:33 [PATCH 1/2] PM: Prototype the pm_generic_ operations Mark Brown
2010-12-20 14:33 ` Mark Brown
2010-12-20 14:33 ` [PATCH 2/2] i2c: Factor out runtime suspend checks from PM operations Mark Brown
2010-12-20 14:33 ` Mark Brown [this message]
2010-12-22 15:10   ` [linux-pm] " Rabin Vincent
2010-12-22 15:10     ` Rabin Vincent
2010-12-22 15:25     ` Mark Brown
2010-12-22 15:25       ` Mark Brown
2010-12-22 21:08       ` Rafael J. Wysocki
2010-12-22 21:08         ` Rafael J. Wysocki
2010-12-22 21:08       ` Rafael J. Wysocki
2010-12-22 15:25     ` Mark Brown
2010-12-22 15:10   ` Rabin Vincent
2010-12-20 21:08 ` [PATCH 1/2] PM: Prototype the pm_generic_ operations Rafael J. Wysocki
2010-12-20 21:08 ` Rafael J. Wysocki
2010-12-20 21:08   ` Rafael J. Wysocki
2010-12-22 11:43   ` [linux-pm] " Mark Brown
2010-12-22 11:43     ` Mark Brown
2010-12-22 12:15     ` Rafael J. Wysocki
2010-12-22 12:15       ` Rafael J. Wysocki
2010-12-22 12:19       ` Mark Brown
2010-12-22 12:19       ` [linux-pm] " Mark Brown
2010-12-22 12:19         ` Mark Brown
2010-12-22 12:15     ` Rafael J. Wysocki
2010-12-22 11:43   ` Mark Brown
2010-12-24 14:08 ` Rafael J. Wysocki
2010-12-24 14:08 ` Rafael J. Wysocki
2010-12-24 14:08   ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1292855593-30608-2-git-send-email-broonie@opensource.wolfsonmicro.com \
    --to=broonie@opensource.wolfsonmicro.com \
    --cc=ben-linux@fluff.org \
    --cc=khali@linux-fr.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=rjw@sisk.pl \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.