can: flexcan: Use SIMPLE_DEV_PM_OPS
authorFabio Estevam <fabio.estevam@freescale.com>
Mon, 20 May 2013 18:43:43 +0000 (15:43 -0300)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 3 Jun 2013 11:13:49 +0000 (13:13 +0200)
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>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/flexcan.c

index a93cdb29fb3fb74ede9c291b24dfdf0aa506b7aa..f873b9f8d4d4b915411e7963394a52e37f67b47a 100644 (file)
@@ -1131,10 +1131,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);
@@ -1148,9 +1148,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;
@@ -1162,21 +1162,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,
 };