mfd: tps80031: Use struct dev_pm_ops for power management
Laxman Dewangan [Wed, 18 Jul 2012 13:21:55 +0000 (18:21 +0530)]
Make the tps80031 driver define its PM callbacks through a
struct dev_pm_ops object rather than by using legacy PM hooks
in struct i2c_driver

Change-Id: I3963426c26eb7609794c6fe761d69f31ee630cb2
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/117330
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
GVS: Gerrit_Virtual_Submit

drivers/mfd/tps80031.c

index b4c51e3..047c380 100644 (file)
@@ -1316,8 +1316,9 @@ fail:
 }
 
 #ifdef CONFIG_PM
-static int tps80031_i2c_suspend(struct i2c_client *client, pm_message_t state)
+static int tps80031_i2c_suspend(struct device *dev)
 {
+       struct i2c_client *client = to_i2c_client(dev);
        struct tps80031 *tps80031 = i2c_get_clientdata(client);
        if (client->irq)
                disable_irq(client->irq);
@@ -1325,14 +1326,22 @@ static int tps80031_i2c_suspend(struct i2c_client *client, pm_message_t state)
        return 0;
 }
 
-static int tps80031_i2c_resume(struct i2c_client *client)
+static int tps80031_i2c_resume(struct device *dev)
 {
+       struct i2c_client *client = to_i2c_client(dev);
        struct tps80031 *tps80031 = i2c_get_clientdata(client);
        tps80031_backup_battery_charger_control(tps80031, 1);
        if (client->irq)
                enable_irq(client->irq);
        return 0;
 }
+static const struct dev_pm_ops tps80031_dev_pm_ops = {
+       .suspend        = tps80031_i2c_suspend,
+       .resume         = tps80031_i2c_resume,
+};
+#define TPS80031_DEV_PM (&tps80031_dev_pm_ops)
+#else
+#define TPS80031_DEV_PM NULL
 #endif
 
 
@@ -1346,13 +1355,10 @@ static struct i2c_driver tps80031_driver = {
        .driver = {
                .name   = "tps80031",
                .owner  = THIS_MODULE,
+               .pm     = TPS80031_DEV_PM,
        },
        .probe          = tps80031_i2c_probe,
        .remove         = __devexit_p(tps80031_i2c_remove),
-#ifdef CONFIG_PM
-       .suspend        = tps80031_i2c_suspend,
-       .resume         = tps80031_i2c_resume,
-#endif
        .id_table       = tps80031_id_table,
 };