]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging:iio: Use dev_pm_ops
authorLars-Peter Clausen <lars@metafoo.de>
Mon, 20 Feb 2012 18:37:05 +0000 (19:37 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Feb 2012 20:11:13 +0000 (12:11 -0800)
Use dev_pm_ops instead of legacy suspend/resume callbacks for IIO drivers.

Note that this patch introduces a few new #ifdef CONFIG_PM_SLEEP around the
suspend and resume callbacks to avoid warnings of unused functions if
CONFIG_PM_SLEEP is not defined.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/iio/addac/adt7316-i2c.c
drivers/staging/iio/addac/adt7316-spi.c
drivers/staging/iio/addac/adt7316.c
drivers/staging/iio/addac/adt7316.h
drivers/staging/iio/dac/max517.c
drivers/staging/iio/light/tsl2563.c
drivers/staging/iio/light/tsl2583.c
drivers/staging/iio/magnetometer/hmc5843.c

index 2c03a39220e8f87d30653b27cf6ac38858698ec8..9e128dd7d457a2c6389cf8dc5be2ae086d31f272 100644 (file)
@@ -125,30 +125,14 @@ static const struct i2c_device_id adt7316_i2c_id[] = {
 
 MODULE_DEVICE_TABLE(i2c, adt7316_i2c_id);
 
-#ifdef CONFIG_PM
-static int adt7316_i2c_suspend(struct i2c_client *client, pm_message_t message)
-{
-       return adt7316_disable(&client->dev);
-}
-
-static int adt7316_i2c_resume(struct i2c_client *client)
-{
-       return adt7316_enable(&client->dev);
-}
-#else
-# define adt7316_i2c_suspend NULL
-# define adt7316_i2c_resume  NULL
-#endif
-
 static struct i2c_driver adt7316_driver = {
        .driver = {
                .name = "adt7316",
+               .pm = ADT7316_PM_OPS,
                .owner  = THIS_MODULE,
        },
        .probe = adt7316_i2c_probe,
        .remove = __devexit_p(adt7316_i2c_remove),
-       .suspend = adt7316_i2c_suspend,
-       .resume = adt7316_i2c_resume,
        .id_table = adt7316_i2c_id,
 };
 module_i2c_driver(adt7316_driver);
index 1ea3cd06299de93af117900c7e91fc40fbbefc25..985f7d8a6eb245ac08a6162509618c4a1abe9936 100644 (file)
@@ -133,30 +133,14 @@ static const struct spi_device_id adt7316_spi_id[] = {
 
 MODULE_DEVICE_TABLE(spi, adt7316_spi_id);
 
-#ifdef CONFIG_PM
-static int adt7316_spi_suspend(struct spi_device *spi_dev, pm_message_t message)
-{
-       return adt7316_disable(&spi_dev->dev);
-}
-
-static int adt7316_spi_resume(struct spi_device *spi_dev)
-{
-       return adt7316_enable(&spi_dev->dev);
-}
-#else
-# define adt7316_spi_suspend NULL
-# define adt7316_spi_resume  NULL
-#endif
-
 static struct spi_driver adt7316_driver = {
        .driver = {
                .name = "adt7316",
+               .pm = ADT7316_PM_OPS,
                .owner = THIS_MODULE,
        },
        .probe = adt7316_spi_probe,
        .remove = __devexit_p(adt7316_spi_remove),
-       .suspend = adt7316_spi_suspend,
-       .resume = adt7316_spi_resume,
        .id_table = adt7316_spi_id,
 };
 module_spi_driver(adt7316_driver);
index 13c39292d3f2fbb5ebad81a3ca023168d0aee152..fd6a4544405896b6960d1a6d9efee7140940ff4a 100644 (file)
@@ -2089,24 +2089,25 @@ static struct attribute_group adt7516_event_attribute_group = {
        .name = "events",
 };
 
-#ifdef CONFIG_PM
-int adt7316_disable(struct device *dev)
+#ifdef CONFIG_PM_SLEEP
+static int adt7316_disable(struct device *dev)
 {
        struct iio_dev *dev_info = dev_get_drvdata(dev);
        struct adt7316_chip_info *chip = iio_priv(dev_info);
 
        return _adt7316_store_enabled(chip, 0);
 }
-EXPORT_SYMBOL(adt7316_disable);
 
-int adt7316_enable(struct device *dev)
+static int adt7316_enable(struct device *dev)
 {
        struct iio_dev *dev_info = dev_get_drvdata(dev);
        struct adt7316_chip_info *chip = iio_priv(dev_info);
 
        return _adt7316_store_enabled(chip, 1);
 }
-EXPORT_SYMBOL(adt7316_enable);
+
+SIMPLE_DEV_PM_OPS(adt7316_pm_ops, adt7316_disable, adt7316_enable);
+EXPORT_SYMBOL_GPL(adt7316_pm_ops);
 #endif
 
 static const struct iio_info adt7316_info = {
index d34bd679bb4e599ec4d8d37757df4a3dbe4fead2..4d3efff46ae7144b8c218434dc8e8fa22ef21ae4 100644 (file)
@@ -10,6 +10,7 @@
 #define _ADT7316_H_
 
 #include <linux/types.h>
+#include <linux/pm.h>
 
 #define ADT7316_REG_MAX_ADDR           0x3F
 
@@ -23,9 +24,11 @@ struct adt7316_bus {
        int (*multi_write) (void *client, u8 first_reg, u8 count, u8 *data);
 };
 
-#ifdef CONFIG_PM
-int adt7316_disable(struct device *dev);
-int adt7316_enable(struct device *dev);
+#ifdef CONFIG_PM_SLEEP
+extern const struct dev_pm_ops adt7316_pm_ops;
+#define ADT7316_PM_OPS (&adt7316_pm_ops)
+#else
+#define ADT7316_PM_OPS NULL
 #endif
 int adt7316_probe(struct device *dev, struct adt7316_bus *bus, const char *name);
 int adt7316_remove(struct device *dev);
index a4df6d7443c1f4db15f59a5c0d2dee8b92e2fcdd..41483c72cec151bf8c9adc5ba40e35ef74fcf3db 100644 (file)
@@ -179,20 +179,27 @@ static struct attribute_group max518_attribute_group = {
        .attrs = max518_attributes,
 };
 
-static int max517_suspend(struct i2c_client *client, pm_message_t mesg)
+#ifdef CONFIG_PM_SLEEP
+static int max517_suspend(struct device *dev)
 {
        u8 outbuf = COMMAND_PD;
 
-       return i2c_master_send(client, &outbuf, 1);
+       return i2c_master_send(to_i2c_client(dev), &outbuf, 1);
 }
 
-static int max517_resume(struct i2c_client *client)
+static int max517_resume(struct device *dev)
 {
        u8 outbuf = 0;
 
-       return i2c_master_send(client, &outbuf, 1);
+       return i2c_master_send(to_i2c_client(dev), &outbuf, 1);
 }
 
+static SIMPLE_DEV_PM_OPS(max517_pm_ops, max517_suspend, max517_resume);
+#define MAX517_PM_OPS (&max517_pm_ops)
+#else
+#define MAX517_PM_OPS NULL
+#endif
+
 static const struct iio_info max517_info = {
        .attrs = &max517_attribute_group,
        .driver_module = THIS_MODULE,
@@ -273,11 +280,10 @@ MODULE_DEVICE_TABLE(i2c, max517_id);
 static struct i2c_driver max517_driver = {
        .driver = {
                .name   = MAX517_DRV_NAME,
+               .pm             = MAX517_PM_OPS,
        },
        .probe          = max517_probe,
        .remove         = max517_remove,
-       .suspend        = max517_suspend,
-       .resume         = max517_resume,
        .id_table       = max517_id,
 };
 module_i2c_driver(max517_driver);
index ffca85e81ef55cdacbcd3ac872d5b33bd0dc3462..aca1e0380ef86554622d446d8966df93b504703c 100644 (file)
@@ -118,7 +118,7 @@ struct tsl2563_chip {
        struct delayed_work     poweroff_work;
 
        /* Remember state for suspend and resume functions */
-       pm_message_t            state;
+       bool suspended;
 
        struct tsl2563_gainlevel_coeff const *gainlevel;
 
@@ -315,7 +315,7 @@ static int tsl2563_get_adc(struct tsl2563_chip *chip)
        int retry = 1;
        int ret = 0;
 
-       if (chip->state.event != PM_EVENT_ON)
+       if (chip->suspended)
                goto out;
 
        if (!chip->int_enabled) {
@@ -810,9 +810,10 @@ static int tsl2563_remove(struct i2c_client *client)
        return 0;
 }
 
-static int tsl2563_suspend(struct i2c_client *client, pm_message_t state)
+#ifdef CONFIG_PM_SLEEP
+static int tsl2563_suspend(struct device *dev)
 {
-       struct tsl2563_chip *chip = i2c_get_clientdata(client);
+       struct tsl2563_chip *chip = i2c_get_clientdata(to_i2c_client(dev));
        int ret;
 
        mutex_lock(&chip->lock);
@@ -821,16 +822,16 @@ static int tsl2563_suspend(struct i2c_client *client, pm_message_t state)
        if (ret)
                goto out;
 
-       chip->state = state;
+       chip->suspended = true;
 
 out:
        mutex_unlock(&chip->lock);
        return ret;
 }
 
-static int tsl2563_resume(struct i2c_client *client)
+static int tsl2563_resume(struct device *dev)
 {
-       struct tsl2563_chip *chip = i2c_get_clientdata(client);
+       struct tsl2563_chip *chip = i2c_get_clientdata(to_i2c_client(dev));
        int ret;
 
        mutex_lock(&chip->lock);
@@ -843,13 +844,19 @@ static int tsl2563_resume(struct i2c_client *client)
        if (ret)
                goto out;
 
-       chip->state.event = PM_EVENT_ON;
+       chip->suspended = false;
 
 out:
        mutex_unlock(&chip->lock);
        return ret;
 }
 
+static SIMPLE_DEV_PM_OPS(tsl2563_pm_ops, tsl2563_suspend, tsl2563_resume);
+#define TSL2563_PM_OPS (&tsl2563_pm_ops)
+#else
+#define TSL2563_PM_OPS NULL
+#endif
+
 static const struct i2c_device_id tsl2563_id[] = {
        { "tsl2560", 0 },
        { "tsl2561", 1 },
@@ -862,9 +869,8 @@ MODULE_DEVICE_TABLE(i2c, tsl2563_id);
 static struct i2c_driver tsl2563_i2c_driver = {
        .driver = {
                .name    = "tsl2563",
+               .pm     = TSL2563_PM_OPS,
        },
-       .suspend        = tsl2563_suspend,
-       .resume         = tsl2563_resume,
        .probe          = tsl2563_probe,
        .remove         = __devexit_p(tsl2563_remove),
        .id_table       = tsl2563_id,
index 5b6455a238d8b3c62bd9078bf90758f86f3c848f..9fe9a671ecff96fa55566f80a75345e50521fe1e 100644 (file)
@@ -884,9 +884,10 @@ fail2:
        return ret;
 }
 
-static int taos_suspend(struct i2c_client *client, pm_message_t state)
+#ifdef CONFIG_PM_SLEEP
+static int taos_suspend(struct device *dev)
 {
-       struct iio_dev *indio_dev = i2c_get_clientdata(client);
+       struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
        struct tsl2583_chip *chip = iio_priv(indio_dev);
        int ret = 0;
 
@@ -901,9 +902,9 @@ static int taos_suspend(struct i2c_client *client, pm_message_t state)
        return ret;
 }
 
-static int taos_resume(struct i2c_client *client)
+static int taos_resume(struct device *dev)
 {
-       struct iio_dev *indio_dev = i2c_get_clientdata(client);
+       struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
        struct tsl2583_chip *chip = iio_priv(indio_dev);
        int ret = 0;
 
@@ -916,6 +917,11 @@ static int taos_resume(struct i2c_client *client)
        return ret;
 }
 
+static SIMPLE_DEV_PM_OPS(taos_pm_ops, taos_suspend, taos_resume);
+#define TAOS_PM_OPS (&taos_pm_ops)
+#else
+#define TAOS_PM_OPS NULL
+#endif
 
 static int __devexit taos_remove(struct i2c_client *client)
 {
@@ -937,10 +943,9 @@ MODULE_DEVICE_TABLE(i2c, taos_idtable);
 static struct i2c_driver taos_driver = {
        .driver = {
                .name = "tsl2583",
+               .pm = TAOS_PM_OPS,
        },
        .id_table = taos_idtable,
-       .suspend        = taos_suspend,
-       .resume         = taos_resume,
        .probe = taos_probe,
        .remove = __devexit_p(taos_remove),
 };
index f2e85a9cf196e948f291adf9fc58bf78b8ff3fba..d24992ceb2b0b226a61490f1ca9614b5112f85b8 100644 (file)
@@ -588,19 +588,26 @@ static int hmc5843_remove(struct i2c_client *client)
        return 0;
 }
 
-static int hmc5843_suspend(struct i2c_client *client, pm_message_t mesg)
+#ifdef CONFIG_PM_SLEEP
+static int hmc5843_suspend(struct device *dev)
 {
-       hmc5843_configure(client, MODE_SLEEP);
+       hmc5843_configure(to_i2c_client(dev), MODE_SLEEP);
        return 0;
 }
 
-static int hmc5843_resume(struct i2c_client *client)
+static int hmc5843_resume(struct device *dev)
 {
-       struct hmc5843_data *data = i2c_get_clientdata(client);
-       hmc5843_configure(client, data->operating_mode);
+       struct hmc5843_data *data = i2c_get_clientdata(to_i2c_client(dev));
+       hmc5843_configure(to_i2c_client(dev), data->operating_mode);
        return 0;
 }
 
+static SIMPLE_DEV_PM_OPS(hmc5843_pm_ops, hmc5843_suspend, hmc5843_resume);
+#define HMC5843_PM_OPS (&hmc5843_pm_ops)
+#else
+#define HMC5843_PM_OPS NULL
+#endif
+
 static const struct i2c_device_id hmc5843_id[] = {
        { "hmc5843", 0 },
        { }
@@ -610,14 +617,13 @@ MODULE_DEVICE_TABLE(i2c, hmc5843_id);
 static struct i2c_driver hmc5843_driver = {
        .driver = {
                .name   = "hmc5843",
+               .pm     = HMC5843_PM_OPS,
        },
        .id_table       = hmc5843_id,
        .probe          = hmc5843_probe,
        .remove         = hmc5843_remove,
        .detect         = hmc5843_detect,
        .address_list   = normal_i2c,
-       .suspend        = hmc5843_suspend,
-       .resume         = hmc5843_resume,
 };
 module_i2c_driver(hmc5843_driver);