mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] i2c: Factor out runtime suspend checks from PM operations
@ 2010-12-30 12:40 Mark Brown
  2011-01-04 23:07 ` Abhijeet Dharmapurikar
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2010-12-30 12:40 UTC (permalink / raw)
  To: Jean Delvare, Rafael J. Wysocki
  Cc: linux-kernel, linux-pm, linux-i2c, Rabin Vincent,
	Abhijeet Dharmapurikar, Ben Dooks, Mark Brown

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 |   68 ++++++++++++++---------------------------------
 1 files changed, 20 insertions(+), 48 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 6b4cc56..6793c51 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -196,88 +196,60 @@ 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)
 {
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
-	int ret;
 
 	if (pm)
-		ret = pm->restore ? pm->restore(dev) : 0;
+		return pm_generic_restore(dev);
 	else
-		ret = i2c_legacy_resume(dev);
-
-	if (!ret) {
-		pm_runtime_disable(dev);
-		pm_runtime_set_active(dev);
-		pm_runtime_enable(dev);
-	}
-
-	return ret;
+		return i2c_legacy_resume(dev);
 }
 #else /* !CONFIG_PM_SLEEP */
 #define i2c_device_pm_suspend	NULL
-- 
1.7.2.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: Factor out runtime suspend checks from PM operations
  2010-12-30 12:40 [PATCH] i2c: Factor out runtime suspend checks from PM operations Mark Brown
@ 2011-01-04 23:07 ` Abhijeet Dharmapurikar
  2011-01-04 23:10   ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Abhijeet Dharmapurikar @ 2011-01-04 23:07 UTC (permalink / raw)
  To: Mark Brown
  Cc: Jean Delvare, Rafael J. Wysocki, linux-kernel, linux-pm,
	linux-i2c, Rabin Vincent, Ben Dooks

Mark Brown wrote:
> 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 |   68 ++++++++++++++---------------------------------
>  1 files changed, 20 insertions(+), 48 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 6b4cc56..6793c51 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -196,88 +196,60 @@ 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);


pm_generic_suspend() and others needs to be externed in linux/pm_runtime.h?

--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm 
Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: Factor out runtime suspend checks from PM operations
  2011-01-04 23:07 ` Abhijeet Dharmapurikar
@ 2011-01-04 23:10   ` Mark Brown
  2011-01-05  8:28     ` Rafael J. Wysocki
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2011-01-04 23:10 UTC (permalink / raw)
  To: Abhijeet Dharmapurikar
  Cc: Jean Delvare, Rafael J. Wysocki, linux-kernel, linux-pm,
	linux-i2c, Rabin Vincent, Ben Dooks

On Tue, Jan 04, 2011 at 03:07:37PM -0800, Abhijeet Dharmapurikar wrote:
> Mark Brown wrote:

>> device op. The PM core provides pm_generic_ functions implementing this
>> behaviour - use them to reduce coupling with future PM updates.

> pm_generic_suspend() and others needs to be externed in linux/pm_runtime.h?

Yes, there's a patch in -next for this already so this patch would need
to either wait for later in the merge window or go in via the PM tree
with the preceeding one (the original version of this patch was posted
as part of a series with the export patch).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: Factor out runtime suspend checks from PM operations
  2011-01-04 23:10   ` Mark Brown
@ 2011-01-05  8:28     ` Rafael J. Wysocki
  2011-01-13 20:17       ` Jean Delvare
  0 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2011-01-05  8:28 UTC (permalink / raw)
  To: Mark Brown
  Cc: Abhijeet Dharmapurikar, Jean Delvare, linux-kernel, linux-pm,
	linux-i2c, Rabin Vincent, Ben Dooks

On Wednesday, January 05, 2011, Mark Brown wrote:
> On Tue, Jan 04, 2011 at 03:07:37PM -0800, Abhijeet Dharmapurikar wrote:
> > Mark Brown wrote:
> 
> >> device op. The PM core provides pm_generic_ functions implementing this
> >> behaviour - use them to reduce coupling with future PM updates.
> 
> > pm_generic_suspend() and others needs to be externed in linux/pm_runtime.h?
> 
> Yes, there's a patch in -next for this already so this patch would need
> to either wait for later in the merge window or go in via the PM tree
> with the preceeding one (the original version of this patch was posted
> as part of a series with the export patch).

I would take it, but I'm still waiting for a word from Jean.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: Factor out runtime suspend checks from PM operations
  2011-01-05  8:28     ` Rafael J. Wysocki
@ 2011-01-13 20:17       ` Jean Delvare
  2011-01-13 20:28         ` Rafael J. Wysocki
  0 siblings, 1 reply; 6+ messages in thread
From: Jean Delvare @ 2011-01-13 20:17 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Mark Brown, Abhijeet Dharmapurikar, linux-kernel, linux-pm,
	linux-i2c, Rabin Vincent, Ben Dooks

Hi Rafael,

On Wed, 5 Jan 2011 09:28:53 +0100, Rafael J. Wysocki wrote:
> On Wednesday, January 05, 2011, Mark Brown wrote:
> > On Tue, Jan 04, 2011 at 03:07:37PM -0800, Abhijeet Dharmapurikar wrote:
> > > Mark Brown wrote:
> > 
> > >> device op. The PM core provides pm_generic_ functions implementing this
> > >> behaviour - use them to reduce coupling with future PM updates.
> > 
> > > pm_generic_suspend() and others needs to be externed in linux/pm_runtime.h?
> > 
> > Yes, there's a patch in -next for this already so this patch would need
> > to either wait for later in the merge window or go in via the PM tree
> > with the preceeding one (the original version of this patch was posted
> > as part of a series with the export patch).
> 
> I would take it, but I'm still waiting for a word from Jean.

Sorry for the long silence, I was on vacation. I've just applied this
patch, and I will send it to Linus tomorrow.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: Factor out runtime suspend checks from PM operations
  2011-01-13 20:17       ` Jean Delvare
@ 2011-01-13 20:28         ` Rafael J. Wysocki
  0 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2011-01-13 20:28 UTC (permalink / raw)
  To: Jean Delvare
  Cc: Mark Brown, Abhijeet Dharmapurikar, linux-kernel, linux-pm,
	linux-i2c, Rabin Vincent, Ben Dooks

On Thursday, January 13, 2011, Jean Delvare wrote:
> Hi Rafael,
> 
> On Wed, 5 Jan 2011 09:28:53 +0100, Rafael J. Wysocki wrote:
> > On Wednesday, January 05, 2011, Mark Brown wrote:
> > > On Tue, Jan 04, 2011 at 03:07:37PM -0800, Abhijeet Dharmapurikar wrote:
> > > > Mark Brown wrote:
> > > 
> > > >> device op. The PM core provides pm_generic_ functions implementing this
> > > >> behaviour - use them to reduce coupling with future PM updates.
> > > 
> > > > pm_generic_suspend() and others needs to be externed in linux/pm_runtime.h?
> > > 
> > > Yes, there's a patch in -next for this already so this patch would need
> > > to either wait for later in the merge window or go in via the PM tree
> > > with the preceeding one (the original version of this patch was posted
> > > as part of a series with the export patch).
> > 
> > I would take it, but I'm still waiting for a word from Jean.
> 
> Sorry for the long silence, I was on vacation. I've just applied this
> patch, and I will send it to Linus tomorrow.

Great, thanks!

Rafael

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-01-13 20:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-30 12:40 [PATCH] i2c: Factor out runtime suspend checks from PM operations Mark Brown
2011-01-04 23:07 ` Abhijeet Dharmapurikar
2011-01-04 23:10   ` Mark Brown
2011-01-05  8:28     ` Rafael J. Wysocki
2011-01-13 20:17       ` Jean Delvare
2011-01-13 20:28         ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®