linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] can: flexcan: Use SIMPLE_DEV_PM_OPS
@ 2013-05-20 18:43 Fabio Estevam
  2013-05-20 18:47 ` Marc Kleine-Budde
  0 siblings, 1 reply; 2+ messages in thread
From: Fabio Estevam @ 2013-05-20 18:43 UTC (permalink / raw)
  To: mkl; +Cc: linux-can, Fabio Estevam

Using SIMPLE_DEV_PM_OPS can make the code smaller and simpler.
    
Also change CONFIG_PM to CONFIG_PM_SLEEP.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/net/can/flexcan.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 4a40a18..d85d9ff 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -1137,10 +1137,10 @@ static int flexcan_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int flexcan_suspend(struct platform_device *pdev, pm_message_t state)
+#ifdef CONFIG_PM_SLEEP
+static int flexcan_suspend(struct device *device)
 {
-	struct net_device *dev = platform_get_drvdata(pdev);
+	struct net_device *dev = dev_get_drvdata(device);
 	struct flexcan_priv *priv = netdev_priv(dev);
 
 	flexcan_chip_disable(priv);
@@ -1154,9 +1154,9 @@ static int flexcan_suspend(struct platform_device *pdev, pm_message_t state)
 	return 0;
 }
 
-static int flexcan_resume(struct platform_device *pdev)
+static int flexcan_resume(struct device *device)
 {
-	struct net_device *dev = platform_get_drvdata(pdev);
+	struct net_device *dev = dev_get_drvdata(device);
 	struct flexcan_priv *priv = netdev_priv(dev);
 
 	priv->can.state = CAN_STATE_ERROR_ACTIVE;
@@ -1168,21 +1168,19 @@ static int flexcan_resume(struct platform_device *pdev)
 
 	return 0;
 }
-#else
-#define flexcan_suspend NULL
-#define flexcan_resume NULL
-#endif
+#endif /* CONFIG_PM_SLEEP */
+
+static SIMPLE_DEV_PM_OPS(flexcan_pm_ops, flexcan_suspend, flexcan_resume);
 
 static struct platform_driver flexcan_driver = {
 	.driver = {
 		.name = DRV_NAME,
 		.owner = THIS_MODULE,
+		.pm	= &flexcan_pm_ops,
 		.of_match_table = flexcan_of_match,
 	},
 	.probe = flexcan_probe,
 	.remove = flexcan_remove,
-	.suspend = flexcan_suspend,
-	.resume = flexcan_resume,
 	.id_table = flexcan_id_table,
 };
 
-- 
1.8.1.2



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

* Re: [PATCH] can: flexcan: Use SIMPLE_DEV_PM_OPS
  2013-05-20 18:43 [PATCH] can: flexcan: Use SIMPLE_DEV_PM_OPS Fabio Estevam
@ 2013-05-20 18:47 ` Marc Kleine-Budde
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2013-05-20 18:47 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: linux-can

[-- Attachment #1: Type: text/plain, Size: 2364 bytes --]

On 05/20/2013 08:43 PM, Fabio Estevam wrote:
> Using SIMPLE_DEV_PM_OPS can make the code smaller and simpler.
>     
> Also change CONFIG_PM to CONFIG_PM_SLEEP.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  drivers/net/can/flexcan.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> index 4a40a18..d85d9ff 100644
> --- a/drivers/net/can/flexcan.c
> +++ b/drivers/net/can/flexcan.c
> @@ -1137,10 +1137,10 @@ static int flexcan_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -#ifdef CONFIG_PM
> -static int flexcan_suspend(struct platform_device *pdev, pm_message_t state)
> +#ifdef CONFIG_PM_SLEEP
> +static int flexcan_suspend(struct device *device)
>  {
> -	struct net_device *dev = platform_get_drvdata(pdev);
> +	struct net_device *dev = dev_get_drvdata(device);
>  	struct flexcan_priv *priv = netdev_priv(dev);
>  
>  	flexcan_chip_disable(priv);
> @@ -1154,9 +1154,9 @@ static int flexcan_suspend(struct platform_device *pdev, pm_message_t state)
>  	return 0;
>  }
>  
> -static int flexcan_resume(struct platform_device *pdev)
> +static int flexcan_resume(struct device *device)
>  {
> -	struct net_device *dev = platform_get_drvdata(pdev);
> +	struct net_device *dev = dev_get_drvdata(device);
>  	struct flexcan_priv *priv = netdev_priv(dev);
>  
>  	priv->can.state = CAN_STATE_ERROR_ACTIVE;
> @@ -1168,21 +1168,19 @@ static int flexcan_resume(struct platform_device *pdev)
>  
>  	return 0;
>  }
> -#else
> -#define flexcan_suspend NULL
> -#define flexcan_resume NULL
> -#endif
> +#endif /* CONFIG_PM_SLEEP */
> +
> +static SIMPLE_DEV_PM_OPS(flexcan_pm_ops, flexcan_suspend, flexcan_resume);
>  
>  static struct platform_driver flexcan_driver = {
>  	.driver = {
>  		.name = DRV_NAME,
>  		.owner = THIS_MODULE,
> +		.pm	= &flexcan_pm_ops,

Please just indent with one space after ".pm". No need to resend, I'll
fix it while applying it to linux-can-next.

tnx, Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

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

end of thread, other threads:[~2013-05-20 18:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-20 18:43 [PATCH] can: flexcan: Use SIMPLE_DEV_PM_OPS Fabio Estevam
2013-05-20 18:47 ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).