Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01788c53 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Greg Kroah-Hartman
Browse files

staging:iio: Use dev_pm_ops



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: default avatarLars-Peter Clausen <lars@metafoo.de>
Acked-by: default avatarJonathan Cameron <jic23@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4eeb3335
Loading
Loading
Loading
Loading
+1 −17
Original line number Diff line number Diff line
@@ -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);
+1 −17
Original line number Diff line number Diff line
@@ -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);
+6 −5
Original line number Diff line number Diff line
@@ -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 = {
+6 −3
Original line number Diff line number Diff line
@@ -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);
+12 −6
Original line number Diff line number Diff line
@@ -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);
Loading