public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH][RFC] Driver Core: Rework platform suspend/resume, print warning
@ 2009-06-01 10:20 Magnus Damm
  2009-06-01 18:44 ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Magnus Damm @ 2009-06-01 10:20 UTC (permalink / raw)
  To: linux-pm; +Cc: gregkh

From: Magnus Damm <damm@igel.co.jp>

This patch reworks the platform driver code for legacy
suspend and resume to avoid installing callbacks in
struct device_driver. A warning is also added telling
users to update the platform driver to use dev_pm_ops.

The functions platform_legacy_suspend()/resume() directly
call suspend and resume callbacks in struct platform_driver
instead of wrapping things in platform_drv_suspend()/resume().

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 Compiles fine, but not runtime tested.

 drivers/base/platform.c |   36 ++++++++++++------------------------
 1 file changed, 12 insertions(+), 24 deletions(-)

--- 0009/drivers/base/platform.c
+++ work/drivers/base/platform.c	2009-06-01 18:12:34.000000000 +0900
@@ -470,22 +470,6 @@ static void platform_drv_shutdown(struct
 	drv->shutdown(dev);
 }
 
-static int platform_drv_suspend(struct device *_dev, pm_message_t state)
-{
-	struct platform_driver *drv = to_platform_driver(_dev->driver);
-	struct platform_device *dev = to_platform_device(_dev);
-
-	return drv->suspend(dev, state);
-}
-
-static int platform_drv_resume(struct device *_dev)
-{
-	struct platform_driver *drv = to_platform_driver(_dev->driver);
-	struct platform_device *dev = to_platform_device(_dev);
-
-	return drv->resume(dev);
-}
-
 /**
  * platform_driver_register
  * @drv: platform driver structure
@@ -499,10 +483,10 @@ int platform_driver_register(struct plat
 		drv->driver.remove = platform_drv_remove;
 	if (drv->shutdown)
 		drv->driver.shutdown = platform_drv_shutdown;
-	if (drv->suspend)
-		drv->driver.suspend = platform_drv_suspend;
-	if (drv->resume)
-		drv->driver.resume = platform_drv_resume;
+	if (drv->suspend || drv->resume)
+		pr_warning("Platform driver '%s' needs updating - please use "
+			"dev_pm_ops\n", drv->driver.name);
+
 	return driver_register(&drv->driver);
 }
 EXPORT_SYMBOL_GPL(platform_driver_register);
@@ -634,20 +618,24 @@ static int platform_match(struct device 
 
 static int platform_legacy_suspend(struct device *dev, pm_message_t mesg)
 {
+	struct platform_driver *pdrv = to_platform_driver(dev->driver);
+	struct platform_device *pdev = to_platform_device(dev);
 	int ret = 0;
 
-	if (dev->driver && dev->driver->suspend)
-		ret = dev->driver->suspend(dev, mesg);
+	if (dev->driver && pdrv->suspend)
+		ret = pdrv->suspend(pdev, mesg);
 
 	return ret;
 }
 
 static int platform_legacy_resume(struct device *dev)
 {
+	struct platform_driver *pdrv = to_platform_driver(dev->driver);
+	struct platform_device *pdev = to_platform_device(dev);
 	int ret = 0;
 
-	if (dev->driver && dev->driver->resume)
-		ret = dev->driver->resume(dev);
+	if (dev->driver && pdrv->resume)
+		ret = pdrv->resume(pdev);
 
 	return ret;
 }

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

* Re: [PATCH][RFC] Driver Core: Rework platform suspend/resume, print warning
  2009-06-01 10:20 [PATCH][RFC] Driver Core: Rework platform suspend/resume, print warning Magnus Damm
@ 2009-06-01 18:44 ` Rafael J. Wysocki
  2009-06-01 21:02   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2009-06-01 18:44 UTC (permalink / raw)
  To: Magnus Damm, gregkh; +Cc: linux-pm

On Monday 01 June 2009, Magnus Damm wrote:
> From: Magnus Damm <damm@igel.co.jp>
> 
> This patch reworks the platform driver code for legacy
> suspend and resume to avoid installing callbacks in
> struct device_driver. A warning is also added telling
> users to update the platform driver to use dev_pm_ops.
> 
> The functions platform_legacy_suspend()/resume() directly
> call suspend and resume callbacks in struct platform_driver
> instead of wrapping things in platform_drv_suspend()/resume().
> 
> Signed-off-by: Magnus Damm <damm@igel.co.jp>

Greg, is this patch fine with you?

Rafael


> ---
> 
>  Compiles fine, but not runtime tested.
> 
>  drivers/base/platform.c |   36 ++++++++++++------------------------
>  1 file changed, 12 insertions(+), 24 deletions(-)
> 
> --- 0009/drivers/base/platform.c
> +++ work/drivers/base/platform.c	2009-06-01 18:12:34.000000000 +0900
> @@ -470,22 +470,6 @@ static void platform_drv_shutdown(struct
>  	drv->shutdown(dev);
>  }
>  
> -static int platform_drv_suspend(struct device *_dev, pm_message_t state)
> -{
> -	struct platform_driver *drv = to_platform_driver(_dev->driver);
> -	struct platform_device *dev = to_platform_device(_dev);
> -
> -	return drv->suspend(dev, state);
> -}
> -
> -static int platform_drv_resume(struct device *_dev)
> -{
> -	struct platform_driver *drv = to_platform_driver(_dev->driver);
> -	struct platform_device *dev = to_platform_device(_dev);
> -
> -	return drv->resume(dev);
> -}
> -
>  /**
>   * platform_driver_register
>   * @drv: platform driver structure
> @@ -499,10 +483,10 @@ int platform_driver_register(struct plat
>  		drv->driver.remove = platform_drv_remove;
>  	if (drv->shutdown)
>  		drv->driver.shutdown = platform_drv_shutdown;
> -	if (drv->suspend)
> -		drv->driver.suspend = platform_drv_suspend;
> -	if (drv->resume)
> -		drv->driver.resume = platform_drv_resume;
> +	if (drv->suspend || drv->resume)
> +		pr_warning("Platform driver '%s' needs updating - please use "
> +			"dev_pm_ops\n", drv->driver.name);
> +
>  	return driver_register(&drv->driver);
>  }
>  EXPORT_SYMBOL_GPL(platform_driver_register);
> @@ -634,20 +618,24 @@ static int platform_match(struct device 
>  
>  static int platform_legacy_suspend(struct device *dev, pm_message_t mesg)
>  {
> +	struct platform_driver *pdrv = to_platform_driver(dev->driver);
> +	struct platform_device *pdev = to_platform_device(dev);
>  	int ret = 0;
>  
> -	if (dev->driver && dev->driver->suspend)
> -		ret = dev->driver->suspend(dev, mesg);
> +	if (dev->driver && pdrv->suspend)
> +		ret = pdrv->suspend(pdev, mesg);
>  
>  	return ret;
>  }
>  
>  static int platform_legacy_resume(struct device *dev)
>  {
> +	struct platform_driver *pdrv = to_platform_driver(dev->driver);
> +	struct platform_device *pdev = to_platform_device(dev);
>  	int ret = 0;
>  
> -	if (dev->driver && dev->driver->resume)
> -		ret = dev->driver->resume(dev);
> +	if (dev->driver && pdrv->resume)
> +		ret = pdrv->resume(pdev);
>  
>  	return ret;
>  }

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

* Re: [PATCH][RFC] Driver Core: Rework platform suspend/resume, print warning
  2009-06-01 18:44 ` Rafael J. Wysocki
@ 2009-06-01 21:02   ` Greg KH
  2009-06-01 22:48     ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2009-06-01 21:02 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: linux-pm

On Mon, Jun 01, 2009 at 08:44:27PM +0200, Rafael J. Wysocki wrote:
> On Monday 01 June 2009, Magnus Damm wrote:
> > From: Magnus Damm <damm@igel.co.jp>
> > 
> > This patch reworks the platform driver code for legacy
> > suspend and resume to avoid installing callbacks in
> > struct device_driver. A warning is also added telling
> > users to update the platform driver to use dev_pm_ops.
> > 
> > The functions platform_legacy_suspend()/resume() directly
> > call suspend and resume callbacks in struct platform_driver
> > instead of wrapping things in platform_drv_suspend()/resume().
> > 
> > Signed-off-by: Magnus Damm <damm@igel.co.jp>
> 
> Greg, is this patch fine with you?

Fine with me.  If you want to take it in your tree, feel free to add:
	Acked-by: Greg Kroah-Hartman <gregkh@suse.de>

thanks,

greg k-h

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

* Re: [PATCH][RFC] Driver Core: Rework platform suspend/resume, print warning
  2009-06-01 21:02   ` Greg KH
@ 2009-06-01 22:48     ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2009-06-01 22:48 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-pm

On Monday 01 June 2009, Greg KH wrote:
> On Mon, Jun 01, 2009 at 08:44:27PM +0200, Rafael J. Wysocki wrote:
> > On Monday 01 June 2009, Magnus Damm wrote:
> > > From: Magnus Damm <damm@igel.co.jp>
> > > 
> > > This patch reworks the platform driver code for legacy
> > > suspend and resume to avoid installing callbacks in
> > > struct device_driver. A warning is also added telling
> > > users to update the platform driver to use dev_pm_ops.
> > > 
> > > The functions platform_legacy_suspend()/resume() directly
> > > call suspend and resume callbacks in struct platform_driver
> > > instead of wrapping things in platform_drv_suspend()/resume().
> > > 
> > > Signed-off-by: Magnus Damm <damm@igel.co.jp>
> > 
> > Greg, is this patch fine with you?
> 
> Fine with me.  If you want to take it in your tree, feel free to add:
> 	Acked-by: Greg Kroah-Hartman <gregkh@suse.de>

I will, thanks!

Best,
Rafael

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

end of thread, other threads:[~2009-06-01 22:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-01 10:20 [PATCH][RFC] Driver Core: Rework platform suspend/resume, print warning Magnus Damm
2009-06-01 18:44 ` Rafael J. Wysocki
2009-06-01 21:02   ` Greg KH
2009-06-01 22:48     ` 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