Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: ad7879 - consolidate PM methods

The PM methods are basically the same for SPI and I2C busses, so let's
use the same dev_pm_ops for both of them.

Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

+20 -57
+1 -25
drivers/input/touchscreen/ad7879-i2c.c
··· 16 16 17 17 #define AD7879_DEVID 0x79 /* AD7879-1/AD7889-1 */ 18 18 19 - #ifdef CONFIG_PM_SLEEP 20 - static int ad7879_i2c_suspend(struct device *dev) 21 - { 22 - struct i2c_client *client = to_i2c_client(dev); 23 - struct ad7879 *ts = i2c_get_clientdata(client); 24 - 25 - ad7879_suspend(ts); 26 - 27 - return 0; 28 - } 29 - 30 - static int ad7879_i2c_resume(struct device *dev) 31 - { 32 - struct i2c_client *client = to_i2c_client(dev); 33 - struct ad7879 *ts = i2c_get_clientdata(client); 34 - 35 - ad7879_resume(ts); 36 - 37 - return 0; 38 - } 39 - #endif 40 - 41 - static SIMPLE_DEV_PM_OPS(ad7879_i2c_pm, ad7879_i2c_suspend, ad7879_i2c_resume); 42 - 43 19 /* All registers are word-sized. 44 20 * AD7879 uses a high-byte first convention. 45 21 */ ··· 95 119 .driver = { 96 120 .name = "ad7879", 97 121 .owner = THIS_MODULE, 98 - .pm = &ad7879_i2c_pm, 122 + .pm = &ad7879_pm_ops, 99 123 }, 100 124 .probe = ad7879_i2c_probe, 101 125 .remove = __devexit_p(ad7879_i2c_remove),
+1 -25
drivers/input/touchscreen/ad7879-spi.c
··· 21 21 #define AD7879_WRITECMD(reg) (AD7879_CMD(reg)) 22 22 #define AD7879_READCMD(reg) (AD7879_CMD(reg) | AD7879_CMD_READ) 23 23 24 - #ifdef CONFIG_PM_SLEEP 25 - static int ad7879_spi_suspend(struct device *dev) 26 - { 27 - struct spi_device *spi = to_spi_device(dev); 28 - struct ad7879 *ts = spi_get_drvdata(spi); 29 - 30 - ad7879_suspend(ts); 31 - 32 - return 0; 33 - } 34 - 35 - static int ad7879_spi_resume(struct device *dev) 36 - { 37 - struct spi_device *spi = to_spi_device(dev); 38 - struct ad7879 *ts = spi_get_drvdata(spi); 39 - 40 - ad7879_resume(ts); 41 - 42 - return 0; 43 - } 44 - #endif 45 - 46 - static SIMPLE_DEV_PM_OPS(ad7879_spi_pm, ad7879_spi_suspend, ad7879_spi_resume); 47 - 48 24 /* 49 25 * ad7879_read/write are only used for initial setup and for sysfs controls. 50 26 * The main traffic is done in ad7879_collect(). ··· 151 175 .name = "ad7879", 152 176 .bus = &spi_bus_type, 153 177 .owner = THIS_MODULE, 154 - .pm = &ad7879_spi_pm, 178 + .pm = &ad7879_pm_ops, 155 179 }, 156 180 .probe = ad7879_spi_probe, 157 181 .remove = __devexit_p(ad7879_spi_remove),
+16 -5
drivers/input/touchscreen/ad7879.c
··· 280 280 __ad7879_disable(ts); 281 281 } 282 282 283 - void ad7879_suspend(struct ad7879 *ts) 283 + #ifdef CONFIG_PM_SLEEP 284 + static int ad7879_suspend(struct device *dev) 284 285 { 286 + struct ad7879 *ts = dev_get_drvdata(dev); 287 + 285 288 mutex_lock(&ts->input->mutex); 286 289 287 290 if (!ts->suspended && !ts->disabled && ts->input->users) ··· 293 290 ts->suspended = true; 294 291 295 292 mutex_unlock(&ts->input->mutex); 296 - } 297 - EXPORT_SYMBOL(ad7879_suspend); 298 293 299 - void ad7879_resume(struct ad7879 *ts) 294 + return 0; 295 + } 296 + 297 + static int ad7879_resume(struct device *dev) 300 298 { 299 + struct ad7879 *ts = dev_get_drvdata(dev); 300 + 301 301 mutex_lock(&ts->input->mutex); 302 302 303 303 if (ts->suspended && !ts->disabled && ts->input->users) ··· 309 303 ts->suspended = false; 310 304 311 305 mutex_unlock(&ts->input->mutex); 306 + 307 + return 0; 312 308 } 313 - EXPORT_SYMBOL(ad7879_resume); 309 + #endif 310 + 311 + SIMPLE_DEV_PM_OPS(ad7879_pm_ops, ad7879_suspend, ad7879_resume); 312 + EXPORT_SYMBOL(ad7879_pm_ops); 314 313 315 314 static void ad7879_toggle(struct ad7879 *ts, bool disable) 316 315 {
+2 -2
drivers/input/touchscreen/ad7879.h
··· 21 21 int (*write)(struct device *dev, u8 reg, u16 val); 22 22 }; 23 23 24 - void ad7879_suspend(struct ad7879 *); 25 - void ad7879_resume(struct ad7879 *); 24 + extern const struct dev_pm_ops ad7879_pm_ops; 25 + 26 26 struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned irq, 27 27 const struct ad7879_bus_ops *bops); 28 28 void ad7879_remove(struct ad7879 *);