public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] spi/atmel: improve the system suspend/resume functions implementation
@ 2014-10-21  3:43 Wenyou Yang
  2014-10-21 16:55 ` Kevin Hilman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Wenyou Yang @ 2014-10-21  3:43 UTC (permalink / raw)
  To: linux-arm-kernel

To make it cleaner, the system suspend/resume directly call
the runtime suspend/resume functions
and remove the wapper of CONFIG_PM_RUNTIME, CONFIG_PM_SLEEP.

Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
---
 drivers/spi/spi-atmel.c |   61 ++++++++++++++++++++---------------------------
 1 file changed, 26 insertions(+), 35 deletions(-)

diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 3f50014..6ed1893 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1451,11 +1451,30 @@ static int atmel_spi_remove(struct platform_device *pdev)
 }
 
 #ifdef CONFIG_PM
-#ifdef CONFIG_PM_SLEEP
+static int atmel_spi_runtime_suspend(struct device *dev)
+{
+	struct spi_master *master = dev_get_drvdata(dev);
+	struct atmel_spi *as = spi_master_get_devdata(master);
+
+	clk_disable_unprepare(as->clk);
+	pinctrl_pm_select_sleep_state(dev);
+
+	return 0;
+}
+
+static int atmel_spi_runtime_resume(struct device *dev)
+{
+	struct spi_master *master = dev_get_drvdata(dev);
+	struct atmel_spi *as = spi_master_get_devdata(master);
+
+	pinctrl_pm_select_default_state(dev);
+
+	return clk_prepare_enable(as->clk);
+}
+
 static int atmel_spi_suspend(struct device *dev)
 {
-	struct spi_master	*master = dev_get_drvdata(dev);
-	struct atmel_spi	*as = spi_master_get_devdata(master);
+	struct spi_master *master = dev_get_drvdata(dev);
 	int ret;
 
 	/* Stop the queue running */
@@ -1465,23 +1484,19 @@ static int atmel_spi_suspend(struct device *dev)
 		return ret;
 	}
 
-	if (!pm_runtime_suspended(dev)) {
-		clk_disable_unprepare(as->clk);
-		pinctrl_pm_select_sleep_state(dev);
-	}
+	if (!pm_runtime_suspended(dev))
+		atmel_spi_runtime_suspend(dev);
 
 	return 0;
 }
 
 static int atmel_spi_resume(struct device *dev)
 {
-	struct spi_master	*master = dev_get_drvdata(dev);
-	struct atmel_spi	*as = spi_master_get_devdata(master);
+	struct spi_master *master = dev_get_drvdata(dev);
 	int ret;
 
 	if (!pm_runtime_suspended(dev)) {
-		pinctrl_pm_select_default_state(dev);
-		ret = clk_prepare_enable(as->clk);
+		ret = atmel_spi_runtime_resume(dev);
 		if (ret)
 			return ret;
 	}
@@ -1493,30 +1508,6 @@ static int atmel_spi_resume(struct device *dev)
 
 	return ret;
 }
-#endif
-
-#ifdef CONFIG_PM_RUNTIME
-static int atmel_spi_runtime_suspend(struct device *dev)
-{
-	struct spi_master *master = dev_get_drvdata(dev);
-	struct atmel_spi *as = spi_master_get_devdata(master);
-
-	clk_disable_unprepare(as->clk);
-	pinctrl_pm_select_sleep_state(dev);
-
-	return 0;
-}
-
-static int atmel_spi_runtime_resume(struct device *dev)
-{
-	struct spi_master *master = dev_get_drvdata(dev);
-	struct atmel_spi *as = spi_master_get_devdata(master);
-
-	pinctrl_pm_select_default_state(dev);
-
-	return clk_prepare_enable(as->clk);
-}
-#endif
 
 static const struct dev_pm_ops atmel_spi_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(atmel_spi_suspend, atmel_spi_resume)
-- 
1.7.9.5

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

* [PATCH] spi/atmel: improve the system suspend/resume functions implementation
  2014-10-21  3:43 [PATCH] spi/atmel: improve the system suspend/resume functions implementation Wenyou Yang
@ 2014-10-21 16:55 ` Kevin Hilman
  2014-10-21 17:00 ` Nicolas Ferre
  2014-10-21 21:27 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Kevin Hilman @ 2014-10-21 16:55 UTC (permalink / raw)
  To: linux-arm-kernel

Wenyou Yang <wenyou.yang@atmel.com> writes:

> To make it cleaner, the system suspend/resume directly call
> the runtime suspend/resume functions
> and remove the wapper of CONFIG_PM_RUNTIME, CONFIG_PM_SLEEP.
>
> Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>

Acked-by: Kevin Hilman <khilman@linaro.org>

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

* [PATCH] spi/atmel: improve the system suspend/resume functions implementation
  2014-10-21  3:43 [PATCH] spi/atmel: improve the system suspend/resume functions implementation Wenyou Yang
  2014-10-21 16:55 ` Kevin Hilman
@ 2014-10-21 17:00 ` Nicolas Ferre
  2014-10-21 21:27 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Ferre @ 2014-10-21 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

On 21/10/2014 05:43, Wenyou Yang :
> To make it cleaner, the system suspend/resume directly call
> the runtime suspend/resume functions
> and remove the wapper of CONFIG_PM_RUNTIME, CONFIG_PM_SLEEP.
> 
> Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>

It looks very neat. Thanks Wenyou and Kevin!

If needed:
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

even if I admit that I tend to put my confidence in you guys for this
enhancement ;-)

Bye,

> ---
>  drivers/spi/spi-atmel.c |   61 ++++++++++++++++++++---------------------------
>  1 file changed, 26 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
> index 3f50014..6ed1893 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -1451,11 +1451,30 @@ static int atmel_spi_remove(struct platform_device *pdev)
>  }
>  
>  #ifdef CONFIG_PM
> -#ifdef CONFIG_PM_SLEEP
> +static int atmel_spi_runtime_suspend(struct device *dev)
> +{
> +	struct spi_master *master = dev_get_drvdata(dev);
> +	struct atmel_spi *as = spi_master_get_devdata(master);
> +
> +	clk_disable_unprepare(as->clk);
> +	pinctrl_pm_select_sleep_state(dev);
> +
> +	return 0;
> +}
> +
> +static int atmel_spi_runtime_resume(struct device *dev)
> +{
> +	struct spi_master *master = dev_get_drvdata(dev);
> +	struct atmel_spi *as = spi_master_get_devdata(master);
> +
> +	pinctrl_pm_select_default_state(dev);
> +
> +	return clk_prepare_enable(as->clk);
> +}
> +
>  static int atmel_spi_suspend(struct device *dev)
>  {
> -	struct spi_master	*master = dev_get_drvdata(dev);
> -	struct atmel_spi	*as = spi_master_get_devdata(master);
> +	struct spi_master *master = dev_get_drvdata(dev);
>  	int ret;
>  
>  	/* Stop the queue running */
> @@ -1465,23 +1484,19 @@ static int atmel_spi_suspend(struct device *dev)
>  		return ret;
>  	}
>  
> -	if (!pm_runtime_suspended(dev)) {
> -		clk_disable_unprepare(as->clk);
> -		pinctrl_pm_select_sleep_state(dev);
> -	}
> +	if (!pm_runtime_suspended(dev))
> +		atmel_spi_runtime_suspend(dev);
>  
>  	return 0;
>  }
>  
>  static int atmel_spi_resume(struct device *dev)
>  {
> -	struct spi_master	*master = dev_get_drvdata(dev);
> -	struct atmel_spi	*as = spi_master_get_devdata(master);
> +	struct spi_master *master = dev_get_drvdata(dev);
>  	int ret;
>  
>  	if (!pm_runtime_suspended(dev)) {
> -		pinctrl_pm_select_default_state(dev);
> -		ret = clk_prepare_enable(as->clk);
> +		ret = atmel_spi_runtime_resume(dev);
>  		if (ret)
>  			return ret;
>  	}
> @@ -1493,30 +1508,6 @@ static int atmel_spi_resume(struct device *dev)
>  
>  	return ret;
>  }
> -#endif
> -
> -#ifdef CONFIG_PM_RUNTIME
> -static int atmel_spi_runtime_suspend(struct device *dev)
> -{
> -	struct spi_master *master = dev_get_drvdata(dev);
> -	struct atmel_spi *as = spi_master_get_devdata(master);
> -
> -	clk_disable_unprepare(as->clk);
> -	pinctrl_pm_select_sleep_state(dev);
> -
> -	return 0;
> -}
> -
> -static int atmel_spi_runtime_resume(struct device *dev)
> -{
> -	struct spi_master *master = dev_get_drvdata(dev);
> -	struct atmel_spi *as = spi_master_get_devdata(master);
> -
> -	pinctrl_pm_select_default_state(dev);
> -
> -	return clk_prepare_enable(as->clk);
> -}
> -#endif
>  
>  static const struct dev_pm_ops atmel_spi_pm_ops = {
>  	SET_SYSTEM_SLEEP_PM_OPS(atmel_spi_suspend, atmel_spi_resume)
> 


-- 
Nicolas Ferre

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

* [PATCH] spi/atmel: improve the system suspend/resume functions implementation
  2014-10-21  3:43 [PATCH] spi/atmel: improve the system suspend/resume functions implementation Wenyou Yang
  2014-10-21 16:55 ` Kevin Hilman
  2014-10-21 17:00 ` Nicolas Ferre
@ 2014-10-21 21:27 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2014-10-21 21:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Oct 21, 2014 at 11:43:34AM +0800, Wenyou Yang wrote:
> To make it cleaner, the system suspend/resume directly call
> the runtime suspend/resume functions
> and remove the wapper of CONFIG_PM_RUNTIME, CONFIG_PM_SLEEP.

Applied, thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141021/cf6f0068/attachment-0001.sig>

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

end of thread, other threads:[~2014-10-21 21:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-21  3:43 [PATCH] spi/atmel: improve the system suspend/resume functions implementation Wenyou Yang
2014-10-21 16:55 ` Kevin Hilman
2014-10-21 17:00 ` Nicolas Ferre
2014-10-21 21:27 ` Mark Brown

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