Skip to content

Commit c0a150e

Browse files
jic23dtor
authored andcommitted
Input: ad714x - unify dev_pm_ops using EXPORT_SIMPLE_DEV_PM_OPS()
The I2C and SPI PM callbacks were identical (though wrapped in some bouncing out to the bus specific container of the struct device and then back again to get the drvdata). As such rather than just moving these to SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() take the opportunity to unify the struct dev_pm_ops and use the new EXPORT_SIMPLE_DEV_PM_OPS() macro so that we can drop the unused suspend and resume callbacks as well as the structure if !CONFIG_PM_SLEEP without needing to mark the callbacks __maybe_unused. Signed-off-by: Jonathan Cameron <[email protected]> Cc: Michael Hennerich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 90208b3 commit c0a150e

File tree

4 files changed

+10
-34
lines changed

4 files changed

+10
-34
lines changed

drivers/input/misc/ad714x-i2c.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@
1212
#include <linux/pm.h>
1313
#include "ad714x.h"
1414

15-
static int __maybe_unused ad714x_i2c_suspend(struct device *dev)
16-
{
17-
return ad714x_disable(i2c_get_clientdata(to_i2c_client(dev)));
18-
}
19-
20-
static int __maybe_unused ad714x_i2c_resume(struct device *dev)
21-
{
22-
return ad714x_enable(i2c_get_clientdata(to_i2c_client(dev)));
23-
}
24-
25-
static SIMPLE_DEV_PM_OPS(ad714x_i2c_pm, ad714x_i2c_suspend, ad714x_i2c_resume);
26-
2715
static int ad714x_i2c_write(struct ad714x_chip *chip,
2816
unsigned short reg, unsigned short data)
2917
{
@@ -96,7 +84,7 @@ MODULE_DEVICE_TABLE(i2c, ad714x_id);
9684
static struct i2c_driver ad714x_i2c_driver = {
9785
.driver = {
9886
.name = "ad714x_captouch",
99-
.pm = &ad714x_i2c_pm,
87+
.pm = pm_sleep_ptr(&ad714x_pm),
10088
},
10189
.probe_new = ad714x_i2c_probe,
10290
.id_table = ad714x_id,

drivers/input/misc/ad714x-spi.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,6 @@
1515
#define AD714x_SPI_CMD_PREFIX 0xE000 /* bits 15:11 */
1616
#define AD714x_SPI_READ BIT(10)
1717

18-
static int __maybe_unused ad714x_spi_suspend(struct device *dev)
19-
{
20-
return ad714x_disable(spi_get_drvdata(to_spi_device(dev)));
21-
}
22-
23-
static int __maybe_unused ad714x_spi_resume(struct device *dev)
24-
{
25-
return ad714x_enable(spi_get_drvdata(to_spi_device(dev)));
26-
}
27-
28-
static SIMPLE_DEV_PM_OPS(ad714x_spi_pm, ad714x_spi_suspend, ad714x_spi_resume);
29-
3018
static int ad714x_spi_read(struct ad714x_chip *chip,
3119
unsigned short reg, unsigned short *data, size_t len)
3220
{
@@ -103,7 +91,7 @@ static int ad714x_spi_probe(struct spi_device *spi)
10391
static struct spi_driver ad714x_spi_driver = {
10492
.driver = {
10593
.name = "ad714x_captouch",
106-
.pm = &ad714x_spi_pm,
94+
.pm = pm_sleep_ptr(&ad714x_pm),
10795
},
10896
.probe = ad714x_spi_probe,
10997
};

drivers/input/misc/ad714x.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,9 +1162,9 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
11621162
}
11631163
EXPORT_SYMBOL(ad714x_probe);
11641164

1165-
#ifdef CONFIG_PM
1166-
int ad714x_disable(struct ad714x_chip *ad714x)
1165+
static int ad714x_suspend(struct device *dev)
11671166
{
1167+
struct ad714x_chip *ad714x = dev_get_drvdata(dev);
11681168
unsigned short data;
11691169

11701170
dev_dbg(ad714x->dev, "%s enter\n", __func__);
@@ -1178,10 +1178,10 @@ int ad714x_disable(struct ad714x_chip *ad714x)
11781178

11791179
return 0;
11801180
}
1181-
EXPORT_SYMBOL(ad714x_disable);
11821181

1183-
int ad714x_enable(struct ad714x_chip *ad714x)
1182+
static int ad714x_resume(struct device *dev)
11841183
{
1184+
struct ad714x_chip *ad714x = dev_get_drvdata(dev);
11851185
dev_dbg(ad714x->dev, "%s enter\n", __func__);
11861186

11871187
mutex_lock(&ad714x->mutex);
@@ -1201,8 +1201,8 @@ int ad714x_enable(struct ad714x_chip *ad714x)
12011201

12021202
return 0;
12031203
}
1204-
EXPORT_SYMBOL(ad714x_enable);
1205-
#endif
1204+
1205+
EXPORT_SIMPLE_DEV_PM_OPS(ad714x_pm, ad714x_suspend, ad714x_resume);
12061206

12071207
MODULE_DESCRIPTION("Analog Devices AD714X Capacitance Touch Sensor Driver");
12081208
MODULE_AUTHOR("Barry Song <[email protected]>");

drivers/input/misc/ad714x.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#ifndef _AD714X_H_
99
#define _AD714X_H_
1010

11+
#include <linux/pm.h>
1112
#include <linux/types.h>
1213

1314
#define STAGE_NUM 12
@@ -45,8 +46,7 @@ struct ad714x_chip {
4546

4647
};
4748

48-
int ad714x_disable(struct ad714x_chip *ad714x);
49-
int ad714x_enable(struct ad714x_chip *ad714x);
49+
extern const struct dev_pm_ops ad714x_pm;
5050
struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
5151
ad714x_read_t read, ad714x_write_t write);
5252

0 commit comments

Comments
 (0)