public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] I2C: runtime: Fix checks which make legacy suspend to never get called
@ 2010-09-27 15:46 Rajendra Nayak
       [not found] ` <1285602360-21180-1-git-send-email-rnayak-l0cyMroinI0@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Rajendra Nayak @ 2010-09-27 15:46 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-pm-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	Rajendra Nayak, Rafael J. Wysocki, Ben Dooks, Mark Brown,
	Jean Delvare, Kevin Hilman

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)

Signed-off-by: Rajendra Nayak <rnayak-l0cyMroinI0@public.gmane.org>
Cc: Rafael J. Wysocki <rjw-KKrjLPT3xs0@public.gmane.org>
Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
Cc: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
---
 drivers/i2c/i2c-core.c |   44 ++++++++++++++++++++++++--------------------
 1 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 6649176..712086f 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -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);
 }
-- 
1.7.0.4

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

* Re: [PATCH] I2C: runtime: Fix checks which make legacy suspend to never get called
       [not found] ` <1285602360-21180-1-git-send-email-rnayak-l0cyMroinI0@public.gmane.org>
@ 2010-09-28 21:45   ` Rafael J. Wysocki
       [not found]     ` <201009282345.26363.rjw-KKrjLPT3xs0@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2010-09-28 21:45 UTC (permalink / raw)
  To: Rajendra Nayak
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Ben Dooks,
	Mark Brown, Jean Delvare, Kevin Hilman

On Monday, September 27, 2010, Rajendra Nayak wrote:
> 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.

> Signed-off-by: Rajendra Nayak <rnayak-l0cyMroinI0@public.gmane.org>
> Cc: Rafael J. Wysocki <rjw-KKrjLPT3xs0@public.gmane.org>

Acked-by: Rafael J. Wysocki <rjw-KKrjLPT3xs0@public.gmane.org>

> Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
> Cc: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
> Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
> Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
> ---
>  drivers/i2c/i2c-core.c |   44 ++++++++++++++++++++++++--------------------
>  1 files changed, 24 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 6649176..712086f 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -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);
>  }
> 

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

* Re: [PATCH] I2C: runtime: Fix checks which make legacy suspend to never get called
       [not found]     ` <201009282345.26363.rjw-KKrjLPT3xs0@public.gmane.org>
@ 2010-09-29 12:23       ` Jean Delvare
  0 siblings, 0 replies; 3+ messages in thread
From: Jean Delvare @ 2010-09-29 12:23 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Rajendra Nayak, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Ben Dooks,
	Mark Brown, Kevin Hilman

On Tue, 28 Sep 2010 23:45:26 +0200, Rafael J. Wysocki wrote:
> On Monday, September 27, 2010, Rajendra Nayak wrote:
> > 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.
> 
> > Signed-off-by: Rajendra Nayak <rnayak-l0cyMroinI0@public.gmane.org>
> > Cc: Rafael J. Wysocki <rjw-KKrjLPT3xs0@public.gmane.org>
> 
> Acked-by: Rafael J. Wysocki <rjw-KKrjLPT3xs0@public.gmane.org>
> 
> > Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
> > Cc: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
> > Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
> > Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
> > ---
> >  drivers/i2c/i2c-core.c |   44 ++++++++++++++++++++++++--------------------
> >  1 files changed, 24 insertions(+), 20 deletions(-)

Applied, thanks.

-- 
Jean Delvare

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

end of thread, other threads:[~2010-09-29 12:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-27 15:46 [PATCH] I2C: runtime: Fix checks which make legacy suspend to never get called Rajendra Nayak
     [not found] ` <1285602360-21180-1-git-send-email-rnayak-l0cyMroinI0@public.gmane.org>
2010-09-28 21:45   ` Rafael J. Wysocki
     [not found]     ` <201009282345.26363.rjw-KKrjLPT3xs0@public.gmane.org>
2010-09-29 12:23       ` Jean Delvare

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