Re: [PATCH] staging:iio: Use dev_pm_ops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Shubhrajyoti,

On 02/22/2012 07:24 AM, Shubhrajyoti Datta wrote:
>> diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c
>> index 2c03a39..9e128dd 100644
>> --- a/drivers/staging/iio/addac/adt7316-i2c.c
>> +++ b/drivers/staging/iio/addac/adt7316-i2c.c
>> @@ -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,
> Could  we use simple dev pm ops here?

We do, ADT7316_PM_OPS is defined as a pointer to adt7316_pm_ops, which is
defined with SIMPLE_DEV_PM_OPS. It is just in another module, because
adt7316_i2c and adt7316_par share the same set of suspend/resume functions.

>>                .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);
>> diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c
>> index 1ea3cd0..985f7d8 100644
>> --- a/drivers/staging/iio/addac/adt7316-spi.c
>> +++ b/drivers/staging/iio/addac/adt7316-spi.c
>> @@ -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,
> 
> Could  we use simple dev pm ops here?
> 
>>                .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);
>> diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c
>> index 13c3929..fd6a454 100644
>> --- a/drivers/staging/iio/addac/adt7316.c
>> +++ b/drivers/staging/iio/addac/adt7316.c
>> @@ -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 = {
>> diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h
>> index d34bd67..4d3efff 100644
>> --- a/drivers/staging/iio/addac/adt7316.h
>> +++ b/drivers/staging/iio/addac/adt7316.h
>> @@ -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);
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux