diff options
Diffstat (limited to 'drivers/input/misc')
36 files changed, 346 insertions, 504 deletions
diff --git a/drivers/input/misc/88pm860x_onkey.c b/drivers/input/misc/88pm860x_onkey.c index 685995cad73f..0f8b7ffb3aff 100644 --- a/drivers/input/misc/88pm860x_onkey.c +++ b/drivers/input/misc/88pm860x_onkey.c @@ -110,7 +110,7 @@ static int pm860x_onkey_probe(struct platform_device *pdev) return 0; } -static int __maybe_unused pm860x_onkey_suspend(struct device *dev) +static int pm860x_onkey_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); @@ -119,7 +119,7 @@ static int __maybe_unused pm860x_onkey_suspend(struct device *dev) chip->wakeup_flag |= 1 << PM8607_IRQ_ONKEY; return 0; } -static int __maybe_unused pm860x_onkey_resume(struct device *dev) +static int pm860x_onkey_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); @@ -129,12 +129,13 @@ static int __maybe_unused pm860x_onkey_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(pm860x_onkey_pm_ops, pm860x_onkey_suspend, pm860x_onkey_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(pm860x_onkey_pm_ops, + pm860x_onkey_suspend, pm860x_onkey_resume); static struct platform_driver pm860x_onkey_driver = { .driver = { .name = "88pm860x-onkey", - .pm = &pm860x_onkey_pm_ops, + .pm = pm_sleep_ptr(&pm860x_onkey_pm_ops), }, .probe = pm860x_onkey_probe, }; diff --git a/drivers/input/misc/ad714x-i2c.c b/drivers/input/misc/ad714x-i2c.c index 5ef518a50e63..d8e39f4a57ac 100644 --- a/drivers/input/misc/ad714x-i2c.c +++ b/drivers/input/misc/ad714x-i2c.c @@ -12,18 +12,6 @@ #include <linux/pm.h> #include "ad714x.h" -static int __maybe_unused ad714x_i2c_suspend(struct device *dev) -{ - return ad714x_disable(i2c_get_clientdata(to_i2c_client(dev))); -} - -static int __maybe_unused ad714x_i2c_resume(struct device *dev) -{ - return ad714x_enable(i2c_get_clientdata(to_i2c_client(dev))); -} - -static SIMPLE_DEV_PM_OPS(ad714x_i2c_pm, ad714x_i2c_suspend, ad714x_i2c_resume); - static int ad714x_i2c_write(struct ad714x_chip *chip, unsigned short reg, unsigned short data) { @@ -96,7 +84,7 @@ MODULE_DEVICE_TABLE(i2c, ad714x_id); static struct i2c_driver ad714x_i2c_driver = { .driver = { .name = "ad714x_captouch", - .pm = &ad714x_i2c_pm, + .pm = pm_sleep_ptr(&ad714x_pm), }, .probe_new = ad714x_i2c_probe, .id_table = ad714x_id, diff --git a/drivers/input/misc/ad714x-spi.c b/drivers/input/misc/ad714x-spi.c index 7d3bf434620f..eb13b4cd6594 100644 --- a/drivers/input/misc/ad714x-spi.c +++ b/drivers/input/misc/ad714x-spi.c @@ -15,18 +15,6 @@ #define AD714x_SPI_CMD_PREFIX 0xE000 /* bits 15:11 */ #define AD714x_SPI_READ BIT(10) -static int __maybe_unused ad714x_spi_suspend(struct device *dev) -{ - return ad714x_disable(spi_get_drvdata(to_spi_device(dev))); -} - -static int __maybe_unused ad714x_spi_resume(struct device *dev) -{ - return ad714x_enable(spi_get_drvdata(to_spi_device(dev))); -} - -static SIMPLE_DEV_PM_OPS(ad714x_spi_pm, ad714x_spi_suspend, ad714x_spi_resume); - static int ad714x_spi_read(struct ad714x_chip *chip, unsigned short reg, unsigned short *data, size_t len) { @@ -103,7 +91,7 @@ static int ad714x_spi_probe(struct spi_device *spi) static struct spi_driver ad714x_spi_driver = { .driver = { .name = "ad714x_captouch", - .pm = &ad714x_spi_pm, + .pm = pm_sleep_ptr(&ad714x_pm), }, .probe = ad714x_spi_probe, }; diff --git a/drivers/input/misc/ad714x.c b/drivers/input/misc/ad714x.c index 43132d98feda..1acd8429c56c 100644 --- a/drivers/input/misc/ad714x.c +++ b/drivers/input/misc/ad714x.c @@ -1162,9 +1162,9 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq, } EXPORT_SYMBOL(ad714x_probe); -#ifdef CONFIG_PM -int ad714x_disable(struct ad714x_chip *ad714x) +static int ad714x_suspend(struct device *dev) { + struct ad714x_chip *ad714x = dev_get_drvdata(dev); unsigned short data; dev_dbg(ad714x->dev, "%s enter\n", __func__); @@ -1178,10 +1178,10 @@ int ad714x_disable(struct ad714x_chip *ad714x) return 0; } -EXPORT_SYMBOL(ad714x_disable); -int ad714x_enable(struct ad714x_chip *ad714x) +static int ad714x_resume(struct device *dev) { + struct ad714x_chip *ad714x = dev_get_drvdata(dev); dev_dbg(ad714x->dev, "%s enter\n", __func__); mutex_lock(&ad714x->mutex); @@ -1201,8 +1201,8 @@ int ad714x_enable(struct ad714x_chip *ad714x) return 0; } -EXPORT_SYMBOL(ad714x_enable); -#endif + +EXPORT_SIMPLE_DEV_PM_OPS(ad714x_pm, ad714x_suspend, ad714x_resume); MODULE_DESCRIPTION("Analog Devices AD714X Capacitance Touch Sensor Driver"); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); diff --git a/drivers/input/misc/ad714x.h b/drivers/input/misc/ad714x.h index af847b5f0d0e..dafa12325f27 100644 --- a/drivers/input/misc/ad714x.h +++ b/drivers/input/misc/ad714x.h @@ -8,6 +8,7 @@ #ifndef _AD714X_H_ #define _AD714X_H_ +#include <linux/pm.h> #include <linux/types.h> #define STAGE_NUM 12 @@ -45,8 +46,7 @@ struct ad714x_chip { }; -int ad714x_disable(struct ad714x_chip *ad714x); -int ad714x_enable(struct ad714x_chip *ad714x); +extern const struct dev_pm_ops ad714x_pm; struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq, ad714x_read_t read, ad714x_write_t write); diff --git a/drivers/input/misc/adxl34x-i2c.c b/drivers/input/misc/adxl34x-i2c.c index a8ceea36d80a..1c75d98c85a7 100644 --- a/drivers/input/misc/adxl34x-i2c.c +++ b/drivers/input/misc/adxl34x-i2c.c @@ -105,29 +105,6 @@ static void adxl34x_i2c_remove(struct i2c_client *client) adxl34x_remove(ac); } -static int __maybe_unused adxl34x_i2c_suspend(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct adxl34x *ac = i2c_get_clientdata(client); - - adxl34x_suspend(ac); - - return 0; -} - -static int __maybe_unused adxl34x_i2c_resume(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct adxl34x *ac = i2c_get_clientdata(client); - - adxl34x_resume(ac); - - return 0; -} - -static SIMPLE_DEV_PM_OPS(adxl34x_i2c_pm, adxl34x_i2c_suspend, - adxl34x_i2c_resume); - static const struct i2c_device_id adxl34x_id[] = { { "adxl34x", 0 }, { } @@ -155,7 +132,7 @@ MODULE_DEVICE_TABLE(of, adxl34x_of_id); static struct i2c_driver adxl34x_driver = { .driver = { .name = "adxl34x", - .pm = &adxl34x_i2c_pm, + .pm = pm_sleep_ptr(&adxl34x_pm), .of_match_table = adxl34x_of_id, }, .probe_new = adxl34x_i2c_probe, diff --git a/drivers/input/misc/adxl34x-spi.c b/drivers/input/misc/adxl34x-spi.c index 91e44d4c66f7..f1094a8ccdd5 100644 --- a/drivers/input/misc/adxl34x-spi.c +++ b/drivers/input/misc/adxl34x-spi.c @@ -94,33 +94,10 @@ static void adxl34x_spi_remove(struct spi_device *spi) adxl34x_remove(ac); } -static int __maybe_unused adxl34x_spi_suspend(struct device *dev) -{ - struct spi_device *spi = to_spi_device(dev); - struct adxl34x *ac = spi_get_drvdata(spi); - - adxl34x_suspend(ac); - - return 0; -} - -static int __maybe_unused adxl34x_spi_resume(struct device *dev) -{ - struct spi_device *spi = to_spi_device(dev); - struct adxl34x *ac = spi_get_drvdata(spi); - - adxl34x_resume(ac); - - return 0; -} - -static SIMPLE_DEV_PM_OPS(adxl34x_spi_pm, adxl34x_spi_suspend, - adxl34x_spi_resume); - static struct spi_driver adxl34x_driver = { .driver = { .name = "adxl34x", - .pm = &adxl34x_spi_pm, + .pm = pm_sleep_ptr(&adxl34x_pm), }, .probe = adxl34x_spi_probe, .remove = adxl34x_spi_remove, diff --git a/drivers/input/misc/adxl34x.c b/drivers/input/misc/adxl34x.c index a4af314392a9..eecca671b588 100644 --- a/drivers/input/misc/adxl34x.c +++ b/drivers/input/misc/adxl34x.c @@ -412,8 +412,10 @@ static void __adxl34x_enable(struct adxl34x *ac) AC_WRITE(ac, POWER_CTL, ac->pdata.power_mode | PCTL_MEASURE); } -void adxl34x_suspend(struct adxl34x *ac) +static int adxl34x_suspend(struct device *dev) { + struct adxl34x *ac = dev_get_drvdata(dev); + mutex_lock(&ac->mutex); if (!ac->suspended && !ac->disabled && ac->opened) @@ -422,11 +424,14 @@ void adxl34x_suspend(struct adxl34x *ac) ac->suspended = true; mutex_unlock(&ac->mutex); + + return 0; } -EXPORT_SYMBOL_GPL(adxl34x_suspend); -void adxl34x_resume(struct adxl34x *ac) +static int adxl34x_resume(struct device *dev) { + struct adxl34x *ac = dev_get_drvdata(dev); + mutex_lock(&ac->mutex); if (ac->suspended && !ac->disabled && ac->opened) @@ -435,8 +440,9 @@ void adxl34x_resume(struct adxl34x *ac) ac->suspended = false; mutex_unlock(&ac->mutex); + + return 0; } -EXPORT_SYMBOL_GPL(adxl34x_resume); static ssize_t adxl34x_disable_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -906,6 +912,8 @@ void adxl34x_remove(struct adxl34x *ac) } EXPORT_SYMBOL_GPL(adxl34x_remove); +EXPORT_GPL_SIMPLE_DEV_PM_OPS(adxl34x_pm, adxl34x_suspend, adxl34x_resume); + MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); MODULE_DESCRIPTION("ADXL345/346 Three-Axis Digital Accelerometer Driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/input/misc/adxl34x.h b/drivers/input/misc/adxl34x.h index febf85270fff..f9272a2e7a96 100644 --- a/drivers/input/misc/adxl34x.h +++ b/drivers/input/misc/adxl34x.h @@ -20,11 +20,11 @@ struct adxl34x_bus_ops { int (*write)(struct device *, unsigned char, unsigned char); }; -void adxl34x_suspend(struct adxl34x *ac); -void adxl34x_resume(struct adxl34x *ac); struct adxl34x *adxl34x_probe(struct device *dev, int irq, bool fifo_delay_default, const struct adxl34x_bus_ops *bops); void adxl34x_remove(struct adxl34x *ac); +extern const struct dev_pm_ops adxl34x_pm; + #endif diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c index 04da7916eb70..4581606a28d6 100644 --- a/drivers/input/misc/axp20x-pek.c +++ b/drivers/input/misc/axp20x-pek.c @@ -336,7 +336,7 @@ static int axp20x_pek_probe(struct platform_device *pdev) return 0; } -static int __maybe_unused axp20x_pek_suspend(struct device *dev) +static int axp20x_pek_suspend(struct device *dev) { struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev); @@ -355,7 +355,7 @@ static int __maybe_unused axp20x_pek_suspend(struct device *dev) return 0; } -static int __maybe_unused axp20x_pek_resume(struct device *dev) +static int axp20x_pek_resume(struct device *dev) { struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev); @@ -389,10 +389,8 @@ static int __maybe_unused axp20x_pek_resume_noirq(struct device *dev) } static const struct dev_pm_ops axp20x_pek_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(axp20x_pek_suspend, axp20x_pek_resume) -#ifdef CONFIG_PM_SLEEP - .resume_noirq = axp20x_pek_resume_noirq, -#endif + SYSTEM_SLEEP_PM_OPS(axp20x_pek_suspend, axp20x_pek_resume) + .resume_noirq = pm_sleep_ptr(axp20x_pek_resume_noirq), }; static const struct platform_device_id axp_pek_id_match[] = { @@ -413,7 +411,7 @@ static struct platform_driver axp20x_pek_driver = { .id_table = axp_pek_id_match, .driver = { .name = "axp20x-pek", - .pm = &axp20x_pek_pm_ops, + .pm = pm_sleep_ptr(&axp20x_pek_pm_ops), .dev_groups = axp20x_groups, }, }; diff --git a/drivers/input/misc/cma3000_d0x_i2c.c b/drivers/input/misc/cma3000_d0x_i2c.c index 75442c1230b1..136eb3715870 100644 --- a/drivers/input/misc/cma3000_d0x_i2c.c +++ b/drivers/input/misc/cma3000_d0x_i2c.c @@ -64,7 +64,6 @@ static void cma3000_i2c_remove(struct i2c_client *client) cma3000_exit(data); } -#ifdef CONFIG_PM static int cma3000_i2c_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -89,7 +88,6 @@ static const struct dev_pm_ops cma3000_i2c_pm_ops = { .suspend = cma3000_i2c_suspend, .resume = cma3000_i2c_resume, }; -#endif static const struct i2c_device_id cma3000_i2c_id[] = { { "cma3000_d01", 0 }, @@ -104,9 +102,7 @@ static struct i2c_driver cma3000_i2c_driver = { .id_table = cma3000_i2c_id, .driver = { .name = "cma3000_i2c_accl", -#ifdef CONFIG_PM - .pm = &cma3000_i2c_pm_ops, -#endif + .pm = pm_sleep_ptr(&cma3000_i2c_pm_ops), }, }; diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c index dcdea33b1a8f..b85a19e3554f 100644 --- a/drivers/input/misc/da7280.c +++ b/drivers/input/misc/da7280.c @@ -1260,7 +1260,7 @@ static int da7280_probe(struct i2c_client *client) return 0; } -static int __maybe_unused da7280_suspend(struct device *dev) +static int da7280_suspend(struct device *dev) { struct da7280_haptic *haptics = dev_get_drvdata(dev); @@ -1281,7 +1281,7 @@ static int __maybe_unused da7280_suspend(struct device *dev) return 0; } -static int __maybe_unused da7280_resume(struct device *dev) +static int da7280_resume(struct device *dev) { struct da7280_haptic *haptics = dev_get_drvdata(dev); int retval; @@ -1313,13 +1313,13 @@ static const struct i2c_device_id da7280_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, da7280_i2c_id); -static SIMPLE_DEV_PM_OPS(da7280_pm_ops, da7280_suspend, da7280_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(da7280_pm_ops, da7280_suspend, da7280_resume); static struct i2c_driver da7280_driver = { .driver = { .name = "da7280", .of_match_table = of_match_ptr(da7280_of_match), - .pm = &da7280_pm_ops, + .pm = pm_sleep_ptr(&da7280_pm_ops), }, .probe_new = da7280_probe, .id_table = da7280_i2c_id, diff --git a/drivers/input/misc/drv260x.c b/drivers/input/misc/drv260x.c index 3a51ee5e935a..8a9ebfc04a2d 100644 --- a/drivers/input/misc/drv260x.c +++ b/drivers/input/misc/drv260x.c @@ -572,7 +572,7 @@ static int drv260x_probe(struct i2c_client *client) return 0; } -static int __maybe_unused drv260x_suspend(struct device *dev) +static int drv260x_suspend(struct device *dev) { struct drv260x_data *haptics = dev_get_drvdata(dev); int ret = 0; @@ -604,7 +604,7 @@ out: return ret; } -static int __maybe_unused drv260x_resume(struct device *dev) +static int drv260x_resume(struct device *dev) { struct drv260x_data *haptics = dev_get_drvdata(dev); int ret = 0; @@ -635,7 +635,7 @@ out: return ret; } -static SIMPLE_DEV_PM_OPS(drv260x_pm_ops, drv260x_suspend, drv260x_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(drv260x_pm_ops, drv260x_suspend, drv260x_resume); static const struct i2c_device_id drv260x_id[] = { { "drv2605l", 0 }, @@ -657,7 +657,7 @@ static struct i2c_driver drv260x_driver = { .driver = { .name = "drv260x-haptics", .of_match_table = drv260x_of_match, - .pm = &drv260x_pm_ops, + .pm = pm_sleep_ptr(&drv260x_pm_ops), }, .id_table = drv260x_id, }; diff --git a/drivers/input/misc/drv2665.c b/drivers/input/misc/drv2665.c index c2a2ff980c06..9145096f80ea 100644 --- a/drivers/input/misc/drv2665.c +++ b/drivers/input/misc/drv2665.c @@ -222,7 +222,7 @@ static int drv2665_probe(struct i2c_client *client) return 0; } -static int __maybe_unused drv2665_suspend(struct device *dev) +static int drv2665_suspend(struct device *dev) { struct drv2665_data *haptics = dev_get_drvdata(dev); int ret = 0; @@ -251,7 +251,7 @@ out: return ret; } -static int __maybe_unused drv2665_resume(struct device *dev) +static int drv2665_resume(struct device *dev) { struct drv2665_data *haptics = dev_get_drvdata(dev); int ret = 0; @@ -280,7 +280,7 @@ out: return ret; } -static SIMPLE_DEV_PM_OPS(drv2665_pm_ops, drv2665_suspend, drv2665_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(drv2665_pm_ops, drv2665_suspend, drv2665_resume); static const struct i2c_device_id drv2665_id[] = { { "drv2665", 0 }, @@ -301,7 +301,7 @@ static struct i2c_driver drv2665_driver = { .driver = { .name = "drv2665-haptics", .of_match_table = of_match_ptr(drv2665_of_match), - .pm = &drv2665_pm_ops, + .pm = pm_sleep_ptr(&drv2665_pm_ops), }, .id_table = drv2665_id, }; diff --git a/drivers/input/misc/drv2667.c b/drivers/input/misc/drv2667.c index da7ac63dce4c..88b4dbe3e5b5 100644 --- a/drivers/input/misc/drv2667.c +++ b/drivers/input/misc/drv2667.c @@ -399,7 +399,7 @@ static int drv2667_probe(struct i2c_client *client) return 0; } -static int __maybe_unused drv2667_suspend(struct device *dev) +static int drv2667_suspend(struct device *dev) { struct drv2667_data *haptics = dev_get_drvdata(dev); int ret = 0; @@ -428,7 +428,7 @@ out: return ret; } -static int __maybe_unused drv2667_resume(struct device *dev) +static int drv2667_resume(struct device *dev) { struct drv2667_data *haptics = dev_get_drvdata(dev); int ret = 0; @@ -457,7 +457,7 @@ out: return ret; } -static SIMPLE_DEV_PM_OPS(drv2667_pm_ops, drv2667_suspend, drv2667_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(drv2667_pm_ops, drv2667_suspend, drv2667_resume); static const struct i2c_device_id drv2667_id[] = { { "drv2667", 0 }, @@ -478,7 +478,7 @@ static struct i2c_driver drv2667_driver = { .driver = { .name = "drv2667-haptics", .of_match_table = of_match_ptr(drv2667_of_match), - .pm = &drv2667_pm_ops, + .pm = pm_sleep_ptr(&drv2667_pm_ops), }, .id_table = drv2667_id, }; diff --git a/drivers/input/misc/e3x0-button.c b/drivers/input/misc/e3x0-button.c index e2fde6e1553f..5bd527117470 100644 --- a/drivers/input/misc/e3x0-button.c +++ b/drivers/input/misc/e3x0-button.c @@ -35,7 +35,7 @@ static irqreturn_t e3x0_button_press_handler(int irq, void *data) return IRQ_HANDLED; } -static int __maybe_unused e3x0_button_suspend(struct device *dev) +static int e3x0_button_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); @@ -45,7 +45,7 @@ static int __maybe_unused e3x0_button_suspend(struct device *dev) return 0; } -static int __maybe_unused e3x0_button_resume(struct device *dev) +static int e3x0_button_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); @@ -55,8 +55,8 @@ static int __maybe_unused e3x0_button_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(e3x0_button_pm_ops, - e3x0_button_suspend, e3x0_button_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(e3x0_button_pm_ops, + e3x0_button_suspend, e3x0_button_resume); static int e3x0_button_probe(struct platform_device *pdev) { @@ -122,7 +122,7 @@ static struct platform_driver e3x0_button_driver = { .driver = { .name = "e3x0-button", .of_match_table = of_match_ptr(e3x0_button_match), - .pm = &e3x0_button_pm_ops, + .pm = pm_sleep_ptr(&e3x0_button_pm_ops), }, .probe = e3x0_button_probe, }; diff --git a/drivers/input/misc/gpio-vibra.c b/drivers/input/misc/gpio-vibra.c index f79f75595dd7..134a1309ba92 100644 --- a/drivers/input/misc/gpio-vibra.c +++ b/drivers/input/misc/gpio-vibra.c @@ -157,7 +157,7 @@ static int gpio_vibrator_probe(struct platform_device *pdev) return 0; } -static int __maybe_unused gpio_vibrator_suspend(struct device *dev) +static int gpio_vibrator_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct gpio_vibrator *vibrator = platform_get_drvdata(pdev); @@ -169,7 +169,7 @@ static int __maybe_unused gpio_vibrator_suspend(struct device *dev) return 0; } -static int __maybe_unused gpio_vibrator_resume(struct device *dev) +static int gpio_vibrator_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct gpio_vibrator *vibrator = platform_get_drvdata(pdev); @@ -180,8 +180,8 @@ static int __maybe_unused gpio_vibrator_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(gpio_vibrator_pm_ops, - gpio_vibrator_suspend, gpio_vibrator_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(gpio_vibrator_pm_ops, + gpio_vibrator_suspend, gpio_vibrator_resume); #ifdef CONFIG_OF static const struct of_device_id gpio_vibra_dt_match_table[] = { @@ -195,7 +195,7 @@ static struct platform_driver gpio_vibrator_driver = { .probe = gpio_vibrator_probe, .driver = { .name = "gpio-vibrator", - .pm = &gpio_vibrator_pm_ops, + .pm = pm_sleep_ptr(&gpio_vibrator_pm_ops), .of_match_table = of_match_ptr(gpio_vibra_dt_match_table), }, }; diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c index a348247d3d38..f4c3aff3895b 100644 --- a/drivers/input/misc/iqs269a.c +++ b/drivers/input/misc/iqs269a.c @@ -9,6 +9,7 @@ * axial sliders presented by the device. */ +#include <linux/completion.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/err.h> @@ -96,8 +97,6 @@ #define IQS269_MISC_B_TRACKING_UI_ENABLE BIT(4) #define IQS269_MISC_B_FILT_STR_SLIDER GENMASK(1, 0) -#define IQS269_CHx_SETTINGS 0x8C - #define IQS269_CHx_ENG_A_MEAS_CAP_SIZE BIT(15) #define IQS269_CHx_ENG_A_RX_GND_INACTIVE BIT(13) #define IQS269_CHx_ENG_A_LOCAL_CAP_SIZE BIT(12) @@ -146,14 +145,7 @@ #define IQS269_NUM_CH 8 #define IQS269_NUM_SL 2 -#define IQS269_ATI_POLL_SLEEP_US (iqs269->delay_mult * 10000) -#define IQS269_ATI_POLL_TIMEOUT_US (iqs269->delay_mult * 500000) -#define IQS269_ATI_STABLE_DELAY_MS (iqs269->delay_mult * 150) - -#define IQS269_PWR_MODE_POLL_SLEEP_US IQS269_ATI_POLL_SLEEP_US -#define IQS269_PWR_MODE_POLL_TIMEOUT_US IQS269_ATI_POLL_TIMEOUT_US - -#define iqs269_irq_wait() usleep_range(100, 150) +#define iqs269_irq_wait() usleep_range(200, 250) enum iqs269_local_cap_size { IQS269_LOCAL_CAP_SIZE_0, @@ -245,6 +237,18 @@ struct iqs269_ver_info { u8 padding; } __packed; +struct iqs269_ch_reg { + u8 rx_enable; + u8 tx_enable; + __be16 engine_a; + __be16 engine_b; + __be16 ati_comp; + u8 thresh[3]; + u8 hyst; + u8 assoc_select; + u8 assoc_weight; +} __packed; + struct iqs269_sys_reg { __be16 general; u8 active; @@ -266,18 +270,7 @@ struct iqs269_sys_reg { u8 timeout_swipe; u8 thresh_swipe; u8 redo_ati; -} __packed; - -struct iqs269_ch_reg { - u8 rx_enable; - u8 tx_enable; - __be16 engine_a; - __be16 engine_b; - __be16 ati_comp; - u8 thresh[3]; - u8 hyst; - u8 assoc_select; - u8 assoc_weight; + struct iqs269_ch_reg ch_reg[IQS269_NUM_CH]; } __packed; struct iqs269_flags { @@ -292,13 +285,11 @@ struct iqs269_private { struct regmap *regmap; struct mutex lock; struct iqs269_switch_desc switches[ARRAY_SIZE(iqs269_events)]; - struct iqs269_ch_reg ch_reg[IQS269_NUM_CH]; struct iqs269_sys_reg sys_reg; + struct completion ati_done; struct input_dev *keypad; struct input_dev *slider[IQS269_NUM_SL]; unsigned int keycode[ARRAY_SIZE(iqs269_events) * IQS269_NUM_CH]; - unsigned int suspend_mode; - unsigned int delay_mult; unsigned int ch_num; bool hall_enable; bool ati_current; @@ -307,6 +298,7 @@ struct iqs269_private { static int iqs269_ati_mode_set(struct iqs269_private *iqs269, unsigned int ch_num, unsigned int mode) { + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; u16 engine_a; if (ch_num >= IQS269_NUM_CH) @@ -317,12 +309,12 @@ static int iqs269_ati_mode_set(struct iqs269_private *iqs269, mutex_lock(&iqs269->lock); - engine_a = be16_to_cpu(iqs269->ch_reg[ch_num].engine_a); + engine_a = be16_to_cpu(ch_reg[ch_num].engine_a); engine_a &= ~IQS269_CHx_ENG_A_ATI_MODE_MASK; engine_a |= (mode << IQS269_CHx_ENG_A_ATI_MODE_SHIFT); - iqs269->ch_reg[ch_num].engine_a = cpu_to_be16(engine_a); + ch_reg[ch_num].engine_a = cpu_to_be16(engine_a); iqs269->ati_current = false; mutex_unlock(&iqs269->lock); @@ -333,13 +325,14 @@ static int iqs269_ati_mode_set(struct iqs269_private *iqs269, static int iqs269_ati_mode_get(struct iqs269_private *iqs269, unsigned int ch_num, unsigned int *mode) { + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; u16 engine_a; if (ch_num >= IQS269_NUM_CH) return -EINVAL; mutex_lock(&iqs269->lock); - engine_a = be16_to_cpu(iqs269->ch_reg[ch_num].engine_a); + engine_a = be16_to_cpu(ch_reg[ch_num].engine_a); mutex_unlock(&iqs269->lock); engine_a &= IQS269_CHx_ENG_A_ATI_MODE_MASK; @@ -351,6 +344,7 @@ static int iqs269_ati_mode_get(struct iqs269_private *iqs269, static int iqs269_ati_base_set(struct iqs269_private *iqs269, unsigned int ch_num, unsigned int base) { + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; u16 engine_b; if (ch_num >= IQS269_NUM_CH) @@ -379,12 +373,12 @@ static int iqs269_ati_base_set(struct iqs269_private *iqs269, mutex_lock(&iqs269->lock); - engine_b = be16_to_cpu(iqs269->ch_reg[ch_num].engine_b); + engine_b = be16_to_cpu(ch_reg[ch_num].engine_b); engine_b &= ~IQS269_CHx_ENG_B_ATI_BASE_MASK; engine_b |= base; - iqs269->ch_reg[ch_num].engine_b = cpu_to_be16(engine_b); + ch_reg[ch_num].engine_b = cpu_to_be16(engine_b); iqs269->ati_current = false; mutex_unlock(&iqs269->lock); @@ -395,13 +389,14 @@ static int iqs269_ati_base_set(struct iqs269_private *iqs269, static int iqs269_ati_base_get(struct iqs269_private *iqs269, unsigned int ch_num, unsigned int *base) { + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; u16 engine_b; if (ch_num >= IQS269_NUM_CH) return -EINVAL; mutex_lock(&iqs269->lock); - engine_b = be16_to_cpu(iqs269->ch_reg[ch_num].engine_b); + engine_b = be16_to_cpu(ch_reg[ch_num].engine_b); mutex_unlock(&iqs269->lock); switch (engine_b & IQS269_CHx_ENG_B_ATI_BASE_MASK) { @@ -429,6 +424,7 @@ static int iqs269_ati_base_get(struct iqs269_private *iqs269, static int iqs269_ati_target_set(struct iqs269_private *iqs269, unsigned int ch_num, unsigned int target) { + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; u16 engine_b; if (ch_num >= IQS269_NUM_CH) @@ -439,12 +435,12 @@ static int iqs269_ati_target_set(struct iqs269_private *iqs269, mutex_lock(&iqs269->lock); - engine_b = be16_to_cpu(iqs269->ch_reg[ch_num].engine_b); + engine_b = be16_to_cpu(ch_reg[ch_num].engine_b); engine_b &= ~IQS269_CHx_ENG_B_ATI_TARGET_MASK; engine_b |= target / 32; - iqs269->ch_reg[ch_num].engine_b = cpu_to_be16(engine_b); + ch_reg[ch_num].engine_b = cpu_to_be16(engine_b); iqs269->ati_current = false; mutex_unlock(&iqs269->lock); @@ -455,13 +451,14 @@ static int iqs269_ati_target_set(struct iqs269_private *iqs269, static int iqs269_ati_target_get(struct iqs269_private *iqs269, unsigned int ch_num, unsigned int *target) { + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; u16 engine_b; if (ch_num >= IQS269_NUM_CH) return -EINVAL; mutex_lock(&iqs269->lock); - engine_b = be16_to_cpu(iqs269->ch_reg[ch_num].engine_b); + engine_b = be16_to_cpu(ch_reg[ch_num].engine_b); mutex_unlock(&iqs269->lock); *target = (engine_b & IQS269_CHx_ENG_B_ATI_TARGET_MASK) * 32; @@ -531,13 +528,7 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269, if (fwnode_property_present(ch_node, "azoteq,slider1-select")) iqs269->sys_reg.slider_select[1] |= BIT(reg); - ch_reg = &iqs269->ch_reg[reg]; - - error = regmap_raw_read(iqs269->regmap, - IQS269_CHx_SETTINGS + reg * sizeof(*ch_reg) / 2, - ch_reg, sizeof(*ch_reg)); - if (error) - return error; + ch_reg = &iqs269->sys_reg.ch_reg[reg]; error = iqs269_parse_mask(ch_node, "azoteq,rx-enable", &ch_reg->rx_enable); @@ -694,6 +685,7 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269, dev_err(&client->dev, "Invalid channel %u threshold: %u\n", reg, val); + fwnode_handle_put(ev_node); return -EINVAL; } @@ -707,6 +699,7 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269, dev_err(&client->dev, "Invalid channel %u hysteresis: %u\n", reg, val); + fwnode_handle_put(ev_node); return -EINVAL; } @@ -721,8 +714,16 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269, } } - if (fwnode_property_read_u32(ev_node, "linux,code", &val)) + error = fwnode_property_read_u32(ev_node, "linux,code", &val); + fwnode_handle_put(ev_node); + if (error == -EINVAL) { continue; + } else if (error) { + dev_err(&client->dev, + "Failed to read channel %u code: %d\n", reg, + error); + return error; + } switch (reg) { case IQS269_CHx_HALL_ACTIVE: @@ -759,17 +760,6 @@ static int iqs269_parse_prop(struct iqs269_private *iqs269) iqs269->hall_enable = device_property_present(&client->dev, "azoteq,hall-enable"); - if (!device_property_read_u32(&client->dev, "azoteq,suspend-mode", - &val)) { - if (val > IQS269_SYS_SETTINGS_PWR_MODE_MAX) { - dev_err(&client->dev, "Invalid suspend mode: %u\n", - val); - return -EINVAL; - } - - iqs269->suspend_mode = val; - } - error = regmap_raw_read(iqs269->regmap, IQS269_SYS_SETTINGS, sys_reg, sizeof(*sys_reg)); if (error) @@ -980,13 +970,8 @@ static int iqs269_parse_prop(struct iqs269_private *iqs269) general = be16_to_cpu(sys_reg->general); - if (device_property_present(&client->dev, "azoteq,clk-div")) { + if (device_property_present(&client->dev, "azoteq,clk-div")) general |= IQS269_SYS_SETTINGS_CLK_DIV; - iqs269->delay_mult = 4; - } else { - general &= ~IQS269_SYS_SETTINGS_CLK_DIV; - iqs269->delay_mult = 1; - } /* * Configure the device to automatically switch between normal and low- @@ -997,6 +982,17 @@ static int iqs269_parse_prop(struct iqs269_private *iqs269) general &= ~IQS269_SYS_SETTINGS_DIS_AUTO; general &= ~IQS269_SYS_SETTINGS_PWR_MODE_MASK; + if (!device_property_read_u32(&client->dev, "azoteq,suspend-mode", + &val)) { + if (val > IQS269_SYS_SETTINGS_PWR_MODE_MAX) { + dev_err(&client->dev, "Invalid suspend mode: %u\n", + val); + return -EINVAL; + } + + general |= (val << IQS269_SYS_SETTINGS_PWR_MODE_SHIFT); + } + if (!device_property_read_u32(&client->dev, "azoteq,ulp-update", &val)) { if (val > IQS269_SYS_SETTINGS_ULP_UPDATE_MAX) { @@ -1032,10 +1028,7 @@ static int iqs269_parse_prop(struct iqs269_private *iqs269) static int iqs269_dev_init(struct iqs269_private *iqs269) { - struct iqs269_sys_reg *sys_reg = &iqs269->sys_reg; - struct iqs269_ch_reg *ch_reg; - unsigned int val; - int error, i; + int error; mutex_lock(&iqs269->lock); @@ -1045,38 +1038,17 @@ static int iqs269_dev_init(struct iqs269_private *iqs269) if (error) goto err_mutex; - for (i = 0; i < IQS269_NUM_CH; i++) { - if (!(sys_reg->active & BIT(i))) - continue; - - ch_reg = &iqs269->ch_reg[i]; - - error = regmap_raw_write(iqs269->regmap, - IQS269_CHx_SETTINGS + i * - sizeof(*ch_reg) / 2, ch_reg, - sizeof(*ch_reg)); - if (error) - goto err_mutex; - } - - /* - * The REDO-ATI and ATI channel selection fields must be written in the - * same block write, so every field between registers 0x80 through 0x8B - * (inclusive) must be written as well. - */ - error = regmap_raw_write(iqs269->regmap, IQS269_SYS_SETTINGS, sys_reg, - sizeof(*sys_reg)); + error = regmap_raw_write(iqs269->regmap, IQS269_SYS_SETTINGS, + &iqs269->sys_reg, sizeof(iqs269->sys_reg)); if (error) goto err_mutex; - error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val, - !(val & IQS269_SYS_FLAGS_IN_ATI), - IQS269_ATI_POLL_SLEEP_US, - IQS269_ATI_POLL_TIMEOUT_US); - if (error) - goto err_mutex; + /* + * The following delay gives the device time to deassert its RDY output + * so as to prevent an interrupt from being serviced prematurely. + */ + usleep_range(2000, 2100); - msleep(IQS269_ATI_STABLE_DELAY_MS); iqs269->ati_current = true; err_mutex: @@ -1088,10 +1060,8 @@ err_mutex: static int iqs269_input_init(struct iqs269_private *iqs269) { struct i2c_client *client = iqs269->client; - struct iqs269_flags flags; unsigned int sw_code, keycode; int error, i, j; - u8 dir_mask, state; iqs269->keypad = devm_input_allocate_device(&client->dev); if (!iqs269->keypad) @@ -1104,23 +1074,7 @@ static int iqs269_input_init(struct iqs269_private *iqs269) iqs269->keypad->name = "iqs269a_keypad"; iqs269->keypad->id.bustype = BUS_I2C; - if (iqs269->hall_enable) { - error = regmap_raw_read(iqs269->regmap, IQS269_SYS_FLAGS, - &flags, sizeof(flags)); - if (error) { - dev_err(&client->dev, - "Failed to read initial status: %d\n", error); - return error; - } - } - for (i = 0; i < ARRAY_SIZE(iqs269_events); i++) { - dir_mask = flags.states[IQS269_ST_OFFS_DIR]; - if (!iqs269_events[i].dir_up) - dir_mask = ~dir_mask; - - state = flags.states[iqs269_events[i].st_offs] & dir_mask; - sw_code = iqs269->switches[i].code; for (j = 0; j < IQS269_NUM_CH; j++) { @@ -1133,13 +1087,9 @@ static int iqs269_input_init(struct iqs269_private *iqs269) switch (j) { case IQS269_CHx_HALL_ACTIVE: if (iqs269->hall_enable && - iqs269->switches[i].enabled) { + iqs269->switches[i].enabled) input_set_capability(iqs269->keypad, EV_SW, sw_code); - input_report_switch(iqs269->keypad, - sw_code, - state & BIT(j)); - } fallthrough; case IQS269_CHx_HALL_INACTIVE: @@ -1155,14 +1105,6 @@ static int iqs269_input_init(struct iqs269_private *iqs269) } } - input_sync(iqs269->keypad); - - error = input_register_device(iqs269->keypad); - if (error) { - dev_err(&client->dev, "Failed to register keypad: %d\n", error); - return error; - } - for (i = 0; i < IQS269_NUM_SL; i++) { if (!iqs269->sys_reg.slider_select[i]) continue; @@ -1222,6 +1164,9 @@ static int iqs269_report(struct iqs269_private *iqs269) return error; } + if (be16_to_cpu(flags.system) & IQS269_SYS_FLAGS_IN_ATI) + return 0; + error = regmap_raw_read(iqs269->regmap, IQS269_SLIDER_X, slider_x, sizeof(slider_x)); if (error) { @@ -1284,6 +1229,12 @@ static int iqs269_report(struct iqs269_private *iqs269) input_sync(iqs269->keypad); + /* + * The following completion signals that ATI has finished, any initial + * switch states have been reported and the keypad can be registered. + */ + complete_all(&iqs269->ati_done); + return 0; } @@ -1315,6 +1266,9 @@ static ssize_t counts_show(struct device *dev, if (!iqs269->ati_current || iqs269->hall_enable) return -EPERM; + if (!completion_done(&iqs269->ati_done)) + return -EBUSY; + /* * Unsolicited I2C communication prompts the device to assert its RDY * pin, so disable the interrupt line until the operation is finished @@ -1339,6 +1293,7 @@ static ssize_t hall_bin_show(struct device *dev, struct device_attribute *attr, char *buf) { struct iqs269_private *iqs269 = dev_get_drvdata(dev); + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; struct i2c_client *client = iqs269->client; unsigned int val; int error; @@ -1353,8 +1308,8 @@ static ssize_t hall_bin_show(struct device *dev, if (error) return error; - switch (iqs269->ch_reg[IQS269_CHx_HALL_ACTIVE].rx_enable & - iqs269->ch_reg[IQS269_CHx_HALL_INACTIVE].rx_enable) { + switch (ch_reg[IQS269_CHx_HALL_ACTIVE].rx_enable & + ch_reg[IQS269_CHx_HALL_INACTIVE].rx_enable) { case IQS269_HALL_PAD_R: val &= IQS269_CAL_DATA_A_HALL_BIN_R_MASK; val >>= IQS269_CAL_DATA_A_HALL_BIN_R_SHIFT; @@ -1434,9 +1389,10 @@ static ssize_t rx_enable_show(struct device *dev, struct device_attribute *attr, char *buf) { struct iqs269_private *iqs269 = dev_get_drvdata(dev); + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; return scnprintf(buf, PAGE_SIZE, "%u\n", - iqs269->ch_reg[iqs269->ch_num].rx_enable); + ch_reg[iqs269->ch_num].rx_enable); } static ssize_t rx_enable_store(struct device *dev, @@ -1444,6 +1400,7 @@ static ssize_t rx_enable_store(struct device *dev, size_t count) { struct iqs269_private *iqs269 = dev_get_drvdata(dev); + struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; unsigned int val; int error; @@ -1456,7 +1413,7 @@ static ssize_t rx_enable_store(struct device *dev, mutex_lock(&iqs269->lock); - iqs269->ch_reg[iqs269->ch_num].rx_enable = val; + ch_reg[iqs269->ch_num].rx_enable = val; iqs269->ati_current = false; mutex_unlock(&iqs269->lock); @@ -1568,7 +1525,9 @@ static ssize_t ati_trigger_show(struct device *dev, { struct iqs269_private *iqs269 = dev_get_drvdata(dev); - return scnprintf(buf, PAGE_SIZE, "%u\n", iqs269->ati_current); + return scnprintf(buf, PAGE_SIZE, "%u\n", + iqs269->ati_current && + completion_done(&iqs269->ati_done)); } static ssize_t ati_trigger_store(struct device *dev, @@ -1588,6 +1547,7 @@ static ssize_t ati_trigger_store(struct device *dev, return count; disable_irq(client->irq); + reinit_completion(&iqs269->ati_done); error = iqs269_dev_init(iqs269); @@ -1597,6 +1557,10 @@ static ssize_t ati_trigger_store(struct device *dev, if (error) return error; + if (!wait_for_completion_timeout(&iqs269->ati_done, + msecs_to_jiffies(2000))) + return -ETIMEDOUT; + return count; } @@ -1655,6 +1619,7 @@ static int iqs269_probe(struct i2c_client *client) } mutex_init(&iqs269->lock); + init_completion(&iqs269->ati_done); error = regmap_raw_read(iqs269->regmap, IQS269_VER_INFO, &ver_info, sizeof(ver_info)); @@ -1690,6 +1655,22 @@ static int iqs269_probe(struct i2c_client *client) return error; } + if (!wait_for_completion_timeout(&iqs269->ati_done, + msecs_to_jiffies(2000))) { + dev_err(&client->dev, "Failed to complete ATI\n"); + return -ETIMEDOUT; + } + + /* + * The keypad may include one or more switches and is not registered + * until ATI is complete and the initial switch states are read. + */ + error = input_register_device(iqs269->keypad); + if (error) { + dev_err(&client->dev, "Failed to register keypad: %d\n", error); + return error; + } + error = devm_device_add_group(&client->dev, &iqs269_attr_group); if (error) dev_err(&client->dev, "Failed to add attributes: %d\n", error); @@ -1697,113 +1678,61 @@ static int iqs269_probe(struct i2c_client *client) return error; } -static int __maybe_unused iqs269_suspend(struct device *dev) +static u16 iqs269_general_get(struct iqs269_private *iqs269) +{ + u16 general = be16_to_cpu(iqs269->sys_reg.general); + + general &= ~IQS269_SYS_SETTINGS_REDO_ATI; + general &= ~IQS269_SYS_SETTINGS_ACK_RESET; + + return general | IQS269_SYS_SETTINGS_DIS_AUTO; +} + +static int iqs269_suspend(struct device *dev) { struct iqs269_private *iqs269 = dev_get_drvdata(dev); struct i2c_client *client = iqs269->client; - unsigned int val; int error; + u16 general = iqs269_general_get(iqs269); - if (!iqs269->suspend_mode) + if (!(general & IQS269_SYS_SETTINGS_PWR_MODE_MASK)) return 0; disable_irq(client->irq); - /* - * Automatic power mode switching must be disabled before the device is - * forced into any particular power mode. In this case, the device will - * transition into normal-power mode. - */ - error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS, - IQS269_SYS_SETTINGS_DIS_AUTO, ~0); - if (error) - goto err_irq; - - /* - * The following check ensures the device has completed its transition - * into normal-power mode before a manual mode switch is performed. - */ - error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val, - !(val & IQS269_SYS_FLAGS_PWR_MODE_MASK), - IQS269_PWR_MODE_POLL_SLEEP_US, - IQS269_PWR_MODE_POLL_TIMEOUT_US); - if (error) - goto err_irq; - - error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS, - IQS269_SYS_SETTINGS_PWR_MODE_MASK, - iqs269->suspend_mode << - IQS269_SYS_SETTINGS_PWR_MODE_SHIFT); - if (error) - goto err_irq; + error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS, general); - /* - * This last check ensures the device has completed its transition into - * the desired power mode to prevent any spurious interrupts from being - * triggered after iqs269_suspend has already returned. - */ - error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val, - (val & IQS269_SYS_FLAGS_PWR_MODE_MASK) - == (iqs269->suspend_mode << - IQS269_SYS_FLAGS_PWR_MODE_SHIFT), - IQS269_PWR_MODE_POLL_SLEEP_US, - IQS269_PWR_MODE_POLL_TIMEOUT_US); - -err_irq: iqs269_irq_wait(); enable_irq(client->irq); return error; } -static int __maybe_unused iqs269_resume(struct device *dev) +static int iqs269_resume(struct device *dev) { struct iqs269_private *iqs269 = dev_get_drvdata(dev); struct i2c_client *client = iqs269->client; - unsigned int val; int error; + u16 general = iqs269_general_get(iqs269); - if (!iqs269->suspend_mode) + if (!(general & IQS269_SYS_SETTINGS_PWR_MODE_MASK)) return 0; disable_irq(client->irq); - error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS, - IQS269_SYS_SETTINGS_PWR_MODE_MASK, 0); - if (error) - goto err_irq; - - /* - * This check ensures the device has returned to normal-power mode - * before automatic power mode switching is re-enabled. - */ - error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val, - !(val & IQS269_SYS_FLAGS_PWR_MODE_MASK), - IQS269_PWR_MODE_POLL_SLEEP_US, - IQS269_PWR_MODE_POLL_TIMEOUT_US); - if (error) - goto err_irq; - - error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS, - IQS269_SYS_SETTINGS_DIS_AUTO, 0); - if (error) - goto err_irq; - - /* - * This step reports any events that may have been "swallowed" as a - * result of polling PWR_MODE (which automatically acknowledges any - * pending interrupts). - */ - error = iqs269_report(iqs269); + error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS, + general & ~IQS269_SYS_SETTINGS_PWR_MODE_MASK); + if (!error) + error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS, + general & ~IQS269_SYS_SETTINGS_DIS_AUTO); -err_irq: iqs269_irq_wait(); enable_irq(client->irq); return error; } -static SIMPLE_DEV_PM_OPS(iqs269_pm, iqs269_suspend, iqs269_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(iqs269_pm, iqs269_suspend, iqs269_resume); static const struct of_device_id iqs269_of_match[] = { { .compatible = "azoteq,iqs269a" }, @@ -1815,7 +1744,7 @@ static struct i2c_driver iqs269_i2c_driver = { .driver = { .name = "iqs269a", .of_match_table = iqs269_of_match, - .pm = &iqs269_pm, + .pm = pm_sleep_ptr(&iqs269_pm), }, .probe_new = iqs269_probe, }; diff --git a/drivers/input/misc/iqs626a.c b/drivers/input/misc/iqs626a.c index 23b5dd9552dc..90f997a905b5 100644 --- a/drivers/input/misc/iqs626a.c +++ b/drivers/input/misc/iqs626a.c @@ -458,18 +458,15 @@ struct iqs626_private { static noinline_for_stack int iqs626_parse_events(struct iqs626_private *iqs626, - const struct fwnode_handle *ch_node, - enum iqs626_ch_id ch_id) + struct fwnode_handle *ch_node, enum iqs626_ch_id ch_id) { struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; struct i2c_client *client = iqs626->client; - const struct fwnode_handle *ev_node; + struct fwnode_handle *ev_node; const char *ev_name; u8 *thresh, *hyst; - unsigned int thresh_tp[IQS626_NUM_CH_TP_3]; unsigned int val; - int num_ch = iqs626_channels[ch_id].num_ch; - int error, i, j; + int i; switch (ch_id) { case IQS626_CH_ULP_0: @@ -509,7 +506,7 @@ iqs626_parse_events(struct iqs626_private *iqs626, * Trackpad touch events are simply described under the * trackpad child node. */ - ev_node = ch_node; + ev_node = fwnode_handle_get(ch_node); } else { ev_name = iqs626_events[i].name; ev_node = fwnode_get_named_child_node(ch_node, ev_name); @@ -533,6 +530,7 @@ iqs626_parse_events(struct iqs626_private *iqs626, dev_err(&client->dev, "Invalid input type: %u\n", val); + fwnode_handle_put(ev_node); return -EINVAL; } @@ -547,6 +545,7 @@ iqs626_parse_events(struct iqs626_private *iqs626, dev_err(&client->dev, "Invalid %s channel hysteresis: %u\n", fwnode_get_name(ch_node), val); + fwnode_handle_put(ev_node); return -EINVAL; } @@ -567,6 +566,7 @@ iqs626_parse_events(struct iqs626_private *iqs626, dev_err(&client->dev, "Invalid %s channel threshold: %u\n", fwnode_get_name(ch_node), val); + fwnode_handle_put(ev_node); return -EINVAL; } @@ -574,32 +574,9 @@ iqs626_parse_events(struct iqs626_private *iqs626, *thresh = val; else *(thresh + iqs626_events[i].th_offs) = val; - - continue; - } - - if (!fwnode_property_present(ev_node, "azoteq,thresh")) - continue; - - error = fwnode_property_read_u32_array(ev_node, "azoteq,thresh", - thresh_tp, num_ch); - if (error) { - dev_err(&client->dev, - "Failed to read %s channel thresholds: %d\n", - fwnode_get_name(ch_node), error); - return error; } - for (j = 0; j < num_ch; j++) { - if (thresh_tp[j] > IQS626_CHx_THRESH_MAX) { - dev_err(&client->dev, - "Invalid %s channel threshold: %u\n", - fwnode_get_name(ch_node), thresh_tp[j]); - return -EINVAL; - } - - sys_reg->tp_grp_reg.ch_reg_tp[j].thresh = thresh_tp[j]; - } + fwnode_handle_put(ev_node); } return 0; @@ -607,16 +584,13 @@ iqs626_parse_events(struct iqs626_private *iqs626, static noinline_for_stack int iqs626_parse_ati_target(struct iqs626_private *iqs626, - const struct fwnode_handle *ch_node, - enum iqs626_ch_id ch_id) + struct fwnode_handle *ch_node, enum iqs626_ch_id ch_id) { struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; struct i2c_client *client = iqs626->client; - unsigned int ati_base[IQS626_NUM_CH_TP_3]; unsigned int val; u8 *ati_target; - int num_ch = iqs626_channels[ch_id].num_ch; - int error, i; + int i; switch (ch_id) { case IQS626_CH_ULP_0: @@ -683,40 +657,13 @@ iqs626_parse_ati_target(struct iqs626_private *iqs626, *ati_target &= ~IQS626_CHx_ATI_BASE_MASK; *ati_target |= val; - - return 0; - } - - if (!fwnode_property_present(ch_node, "azoteq,ati-base")) - return 0; - - error = fwnode_property_read_u32_array(ch_node, "azoteq,ati-base", - ati_base, num_ch); - if (error) { - dev_err(&client->dev, - "Failed to read %s channel ATI bases: %d\n", - fwnode_get_name(ch_node), error); - return error; - } - - for (i = 0; i < num_ch; i++) { - if (ati_base[i] < IQS626_TPx_ATI_BASE_MIN || - ati_base[i] > IQS626_TPx_ATI_BASE_MAX) { - dev_err(&client->dev, - "Invalid %s channel ATI base: %u\n", - fwnode_get_name(ch_node), ati_base[i]); - return -EINVAL; - } - - ati_base[i] -= IQS626_TPx_ATI_BASE_MIN; - sys_reg->tp_grp_reg.ch_reg_tp[i].ati_base = ati_base[i]; } return 0; } static int iqs626_parse_pins(struct iqs626_private *iqs626, - const struct fwnode_handle *ch_node, + struct fwnode_handle *ch_node, const char *propname, u8 *enable) { struct i2c_client *client = iqs626->client; @@ -764,13 +711,14 @@ static int iqs626_parse_pins(struct iqs626_private *iqs626, } static int iqs626_parse_trackpad(struct iqs626_private *iqs626, - const struct fwnode_handle *ch_node) + struct fwnode_handle *ch_node, + enum iqs626_ch_id ch_id) { struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; struct i2c_client *client = iqs626->client; u8 *hyst = &sys_reg->tp_grp_reg.hyst; + int error, count, i; unsigned int val; - int error, count; if (!fwnode_property_read_u32(ch_node, "azoteq,lta-update", &val)) { if (val > IQS626_MISC_A_TPx_LTA_UPDATE_MAX) { @@ -823,6 +771,48 @@ static int iqs626_parse_trackpad(struct iqs626_private *iqs626, *hyst |= (val << IQS626_FILT_STR_LP_TPx_SHIFT); } + for (i = 0; i < iqs626_channels[ch_id].num_ch; i++) { + u8 *ati_base = &sys_reg->tp_grp_reg.ch_reg_tp[i].ati_base; + u8 *thresh = &sys_reg->tp_grp_reg.ch_reg_tp[i].thresh; + struct fwnode_handle *tc_node; + char tc_name[10]; + + snprintf(tc_name, sizeof(tc_name), "channel-%d", i); + + tc_node = fwnode_get_named_child_node(ch_node, tc_name); + if (!tc_node) + continue; + + if (!fwnode_property_read_u32(tc_node, "azoteq,ati-base", + &val)) { + if (val < IQS626_TPx_ATI_BASE_MIN || + val > IQS626_TPx_ATI_BASE_MAX) { + dev_err(&client->dev, + "Invalid %s %s ATI base: %u\n", + fwnode_get_name(ch_node), tc_name, val); + fwnode_handle_put(tc_node); + return -EINVAL; + } + + *ati_base = val - IQS626_TPx_ATI_BASE_MIN; + } + + if (!fwnode_property_read_u32(tc_node, "azoteq,thresh", + &val)) { + if (val > IQS626_CHx_THRESH_MAX) { + dev_err(&client->dev, + "Invalid %s %s threshold: %u\n", + fwnode_get_name(ch_node), tc_name, val); + fwnode_handle_put(tc_node); + return -EINVAL; + } + + *thresh = val; + } + + fwnode_handle_put(tc_node); + } + if (!fwnode_property_present(ch_node, "linux,keycodes")) return 0; @@ -889,8 +879,7 @@ static int iqs626_parse_trackpad(struct iqs626_private *iqs626, static noinline_for_stack int iqs626_parse_channel(struct iqs626_private *iqs626, - const struct fwnode_handle *ch_node, - enum iqs626_ch_id ch_id) + struct fwnode_handle *ch_node, enum iqs626_ch_id ch_id) { struct iqs626_sys_reg *sys_reg = &iqs626->sys_reg; struct i2c_client *client = iqs626->client; @@ -924,6 +913,20 @@ iqs626_parse_channel(struct iqs626_private *iqs626, return -EINVAL; } + error = iqs626_parse_ati_target(iqs626, ch_node, ch_id); + if (error) + return error; + + error = iqs626_parse_events(iqs626, ch_node, ch_id); + if (error) + return error; + + if (!fwnode_property_present(ch_node, "azoteq,ati-exclude")) + sys_reg->redo_ati |= iqs626_channels[ch_id].active; + + if (!fwnode_property_present(ch_node, "azoteq,reseed-disable")) + sys_reg->reseed |= iqs626_channels[ch_id].active; + *engine |= IQS626_CHx_ENG_0_MEAS_CAP_SIZE; if (fwnode_property_present(ch_node, "azoteq,meas-cap-decrease")) *engine &= ~IQS626_CHx_ENG_0_MEAS_CAP_SIZE; @@ -1057,7 +1060,7 @@ iqs626_parse_channel(struct iqs626_private *iqs626, *(engine + 1) |= IQS626_CHx_ENG_1_ATI_BAND_TIGHTEN; if (ch_id == IQS626_CH_TP_2 || ch_id == IQS626_CH_TP_3) - return iqs626_parse_trackpad(iqs626, ch_node); + return iqs626_parse_trackpad(iqs626, ch_node, ch_id); if (ch_id == IQS626_CH_ULP_0) { sys_reg->ch_reg_ulp.hyst &= ~IQS626_ULP_PROJ_ENABLE; @@ -1378,23 +1381,10 @@ static int iqs626_parse_prop(struct iqs626_private *iqs626) continue; error = iqs626_parse_channel(iqs626, ch_node, i); + fwnode_handle_put(ch_node); if (error) return error; - error = iqs626_parse_ati_target(iqs626, ch_node, i); - if (error) - return error; - - error = iqs626_parse_events(iqs626, ch_node, i); - if (error) - return error; - - if (!fwnode_property_present(ch_node, "azoteq,ati-exclude")) - sys_reg->redo_ati |= iqs626_channels[i].active; - - if (!fwnode_property_present(ch_node, "azoteq,reseed-disable")) - sys_reg->reseed |= iqs626_channels[i].active; - sys_reg->active |= iqs626_channels[i].active; } @@ -1712,7 +1702,7 @@ static int iqs626_probe(struct i2c_client *client) return error; } -static int __maybe_unused iqs626_suspend(struct device *dev) +static int iqs626_suspend(struct device *dev) { struct iqs626_private *iqs626 = dev_get_drvdata(dev); struct i2c_client *client = iqs626->client; @@ -1771,7 +1761,7 @@ err_irq: return error; } -static int __maybe_unused iqs626_resume(struct device *dev) +static int iqs626_resume(struct device *dev) { struct iqs626_private *iqs626 = dev_get_drvdata(dev); struct i2c_client *client = iqs626->client; @@ -1818,7 +1808,7 @@ err_irq: return error; } -static SIMPLE_DEV_PM_OPS(iqs626_pm, iqs626_suspend, iqs626_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(iqs626_pm, iqs626_suspend, iqs626_resume); static const struct of_device_id iqs626_of_match[] = { { .compatible = "azoteq,iqs626a" }, @@ -1830,7 +1820,7 @@ static struct i2c_driver iqs626_i2c_driver = { .driver = { .name = "iqs626a", .of_match_table = iqs626_of_match, - .pm = &iqs626_pm, + .pm = pm_sleep_ptr(&iqs626_pm), }, .probe_new = iqs626_probe, }; diff --git a/drivers/input/misc/kxtj9.c b/drivers/input/misc/kxtj9.c index 7e73e6e0730f..4e806d56c55d 100644 --- a/drivers/input/misc/kxtj9.c +++ b/drivers/input/misc/kxtj9.c @@ -494,7 +494,7 @@ static int kxtj9_probe(struct i2c_client *client) return 0; } -static int __maybe_unused kxtj9_suspend(struct device *dev) +static int kxtj9_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct kxtj9_data *tj9 = i2c_get_clientdata(client); @@ -509,7 +509,7 @@ static int __maybe_unused kxtj9_suspend(struct device *dev) return 0; } -static int __maybe_unused kxtj9_resume(struct device *dev) +static int kxtj9_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct kxtj9_data *tj9 = i2c_get_clientdata(client); @@ -524,7 +524,7 @@ static int __maybe_unused kxtj9_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(kxtj9_pm_ops, kxtj9_suspend, kxtj9_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(kxtj9_pm_ops, kxtj9_suspend, kxtj9_resume); static const struct i2c_device_id kxtj9_id[] = { { NAME, 0 }, @@ -536,7 +536,7 @@ MODULE_DEVICE_TABLE(i2c, kxtj9_id); static struct i2c_driver kxtj9_driver = { .driver = { .name = NAME, - .pm = &kxtj9_pm_ops, + .pm = pm_sleep_ptr(&kxtj9_pm_ops), }, .probe_new = kxtj9_probe, .id_table = kxtj9_id, diff --git a/drivers/input/misc/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c index 4369d3c04d38..80f4416ffe2f 100644 --- a/drivers/input/misc/max77693-haptic.c +++ b/drivers/input/misc/max77693-haptic.c @@ -375,7 +375,7 @@ static int max77693_haptic_probe(struct platform_device *pdev) return 0; } -static int __maybe_unused max77693_haptic_suspend(struct device *dev) +static int max77693_haptic_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct max77693_haptic *haptic = platform_get_drvdata(pdev); @@ -388,7 +388,7 @@ static int __maybe_unused max77693_haptic_suspend(struct device *dev) return 0; } -static int __maybe_unused max77693_haptic_resume(struct device *dev) +static int max77693_haptic_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct max77693_haptic *haptic = platform_get_drvdata(pdev); @@ -401,8 +401,9 @@ static int __maybe_unused max77693_haptic_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops, - max77693_haptic_suspend, max77693_haptic_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops, + max77693_haptic_suspend, + max77693_haptic_resume); static const struct platform_device_id max77693_haptic_id[] = { { "max77693-haptic", TYPE_MAX77693 }, @@ -414,7 +415,7 @@ MODULE_DEVICE_TABLE(platform, max77693_haptic_id); static struct platform_driver max77693_haptic_driver = { .driver = { .name = "max77693-haptic", - .pm = &max77693_haptic_pm_ops, + .pm = pm_sleep_ptr(&max77693_haptic_pm_ops), }, .probe = max77693_haptic_probe, .id_table = max77693_haptic_id, diff --git a/drivers/input/misc/max8925_onkey.c b/drivers/input/misc/max8925_onkey.c index 4770cb55631a..62619e4fed20 100644 --- a/drivers/input/misc/max8925_onkey.c +++ b/drivers/input/misc/max8925_onkey.c @@ -129,7 +129,7 @@ static int max8925_onkey_probe(struct platform_device *pdev) return 0; } -static int __maybe_unused max8925_onkey_suspend(struct device *dev) +static int max8925_onkey_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct max8925_onkey_info *info = platform_get_drvdata(pdev); @@ -143,7 +143,7 @@ static int __maybe_unused max8925_onkey_suspend(struct device *dev) return 0; } -static int __maybe_unused max8925_onkey_resume(struct device *dev) +static int max8925_onkey_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct max8925_onkey_info *info = platform_get_drvdata(pdev); @@ -157,12 +157,13 @@ static int __maybe_unused max8925_onkey_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(max8925_onkey_pm_ops, max8925_onkey_suspend, max8925_onkey_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(max8925_onkey_pm_ops, + max8925_onkey_suspend, max8925_onkey_resume); static struct platform_driver max8925_onkey_driver = { .driver = { .name = "max8925-onkey", - .pm = &max8925_onkey_pm_ops, + .pm = pm_sleep_ptr(&max8925_onkey_pm_ops), }, .probe = max8925_onkey_probe, }; diff --git a/drivers/input/misc/max8997_haptic.c b/drivers/input/misc/max8997_haptic.c index 99cbc5ee89d1..c4dff476d479 100644 --- a/drivers/input/misc/max8997_haptic.c +++ b/drivers/input/misc/max8997_haptic.c @@ -366,7 +366,7 @@ static int max8997_haptic_remove(struct platform_device *pdev) return 0; } -static int __maybe_unused max8997_haptic_suspend(struct device *dev) +static int max8997_haptic_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct max8997_haptic *chip = platform_get_drvdata(pdev); @@ -376,7 +376,8 @@ static int __maybe_unused max8997_haptic_suspend(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(max8997_haptic_pm_ops, max8997_haptic_suspend, NULL); +static DEFINE_SIMPLE_DEV_PM_OPS(max8997_haptic_pm_ops, + max8997_haptic_suspend, NULL); static const struct platform_device_id max8997_haptic_id[] = { { "max8997-haptic", 0 }, @@ -387,7 +388,7 @@ MODULE_DEVICE_TABLE(platform, max8997_haptic_id); static struct platform_driver max8997_haptic_driver = { .driver = { .name = "max8997-haptic", - .pm = &max8997_haptic_pm_ops, + .pm = pm_sleep_ptr(&max8997_haptic_pm_ops), }, .probe = max8997_haptic_probe, .remove = max8997_haptic_remove, diff --git a/drivers/input/misc/palmas-pwrbutton.c b/drivers/input/misc/palmas-pwrbutton.c index 465e6693077a..7e361727b0d9 100644 --- a/drivers/input/misc/palmas-pwrbutton.c +++ b/drivers/input/misc/palmas-pwrbutton.c @@ -266,7 +266,7 @@ static int palmas_pwron_remove(struct platform_device *pdev) * * Return: 0 */ -static int __maybe_unused palmas_pwron_suspend(struct device *dev) +static int palmas_pwron_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct palmas_pwron *pwron = platform_get_drvdata(pdev); @@ -287,7 +287,7 @@ static int __maybe_unused palmas_pwron_suspend(struct device *dev) * * Return: 0 */ -static int __maybe_unused palmas_pwron_resume(struct device *dev) +static int palmas_pwron_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct palmas_pwron *pwron = platform_get_drvdata(pdev); @@ -298,8 +298,8 @@ static int __maybe_unused palmas_pwron_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(palmas_pwron_pm, - palmas_pwron_suspend, palmas_pwron_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(palmas_pwron_pm, + palmas_pwron_suspend, palmas_pwron_resume); #ifdef CONFIG_OF static const struct of_device_id of_palmas_pwr_match[] = { @@ -316,7 +316,7 @@ static struct platform_driver palmas_pwron_driver = { .driver = { .name = "palmas_pwrbutton", .of_match_table = of_match_ptr(of_palmas_pwr_match), - .pm = &palmas_pwron_pm, + .pm = pm_sleep_ptr(&palmas_pwron_pm), }, }; module_platform_driver(palmas_pwron_driver); diff --git a/drivers/input/misc/pcf8574_keypad.c b/drivers/input/misc/pcf8574_keypad.c index fd1ff3f1cd92..6323c3d37ef7 100644 --- a/drivers/input/misc/pcf8574_keypad.c +++ b/drivers/input/misc/pcf8574_keypad.c @@ -167,7 +167,6 @@ static void pcf8574_kp_remove(struct i2c_client *client) kfree(lp); } -#ifdef CONFIG_PM static int pcf8574_kp_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -186,15 +185,8 @@ static int pcf8574_kp_suspend(struct device *dev) return 0; } -static const struct dev_pm_ops pcf8574_kp_pm_ops = { - .suspend = pcf8574_kp_suspend, - .resume = pcf8574_kp_resume, -}; - -#else -# define pcf8574_kp_resume NULL -# define pcf8574_kp_suspend NULL -#endif +static DEFINE_SIMPLE_DEV_PM_OPS(pcf8574_kp_pm_ops, + pcf8574_kp_suspend, pcf8574_kp_resume); static const struct i2c_device_id pcf8574_kp_id[] = { { DRV_NAME, 0 }, @@ -205,9 +197,7 @@ MODULE_DEVICE_TABLE(i2c, pcf8574_kp_id); static struct i2c_driver pcf8574_kp_driver = { .driver = { .name = DRV_NAME, -#ifdef CONFIG_PM - .pm = &pcf8574_kp_pm_ops, -#endif + .pm = pm_sleep_ptr(&pcf8574_kp_pm_ops), }, .probe_new = pcf8574_kp_probe, .remove = pcf8574_kp_remove, diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c index 549df01b6ee3..b6a27ebae977 100644 --- a/drivers/input/misc/pm8941-pwrkey.c +++ b/drivers/input/misc/pm8941-pwrkey.c @@ -217,7 +217,7 @@ static int pm8941_pwrkey_sw_debounce_init(struct pm8941_pwrkey *pwrkey) return 0; } -static int __maybe_unused pm8941_pwrkey_suspend(struct device *dev) +static int pm8941_pwrkey_suspend(struct device *dev) { struct pm8941_pwrkey *pwrkey = dev_get_drvdata(dev); @@ -227,7 +227,7 @@ static int __maybe_unused pm8941_pwrkey_suspend(struct device *dev) return 0; } -static int __maybe_unused pm8941_pwrkey_resume(struct device *dev) +static int pm8941_pwrkey_resume(struct device *dev) { struct pm8941_pwrkey *pwrkey = dev_get_drvdata(dev); @@ -237,8 +237,8 @@ static int __maybe_unused pm8941_pwrkey_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(pm8941_pwr_key_pm_ops, - pm8941_pwrkey_suspend, pm8941_pwrkey_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(pm8941_pwr_key_pm_ops, + pm8941_pwrkey_suspend, pm8941_pwrkey_resume); static int pm8941_pwrkey_probe(struct platform_device *pdev) { @@ -460,7 +460,7 @@ static struct platform_driver pm8941_pwrkey_driver = { .remove = pm8941_pwrkey_remove, .driver = { .name = "pm8941-pwrkey", - .pm = &pm8941_pwr_key_pm_ops, + .pm = pm_sleep_ptr(&pm8941_pwr_key_pm_ops), .of_match_table = of_match_ptr(pm8941_pwr_key_id_table), }, }; diff --git a/drivers/input/misc/pm8xxx-vibrator.c b/drivers/input/misc/pm8xxx-vibrator.c index 53ad25eaf1a2..04cb87efd799 100644 --- a/drivers/input/misc/pm8xxx-vibrator.c +++ b/drivers/input/misc/pm8xxx-vibrator.c @@ -226,7 +226,7 @@ static int pm8xxx_vib_probe(struct platform_device *pdev) return 0; } -static int __maybe_unused pm8xxx_vib_suspend(struct device *dev) +static int pm8xxx_vib_suspend(struct device *dev) { struct pm8xxx_vib *vib = dev_get_drvdata(dev); @@ -236,7 +236,7 @@ static int __maybe_unused pm8xxx_vib_suspend(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(pm8xxx_vib_pm_ops, pm8xxx_vib_suspend, NULL); +static DEFINE_SIMPLE_DEV_PM_OPS(pm8xxx_vib_pm_ops, pm8xxx_vib_suspend, NULL); static const struct of_device_id pm8xxx_vib_id_table[] = { { .compatible = "qcom,pm8058-vib", .data = &pm8058_regs }, @@ -250,7 +250,7 @@ static struct platform_driver pm8xxx_vib_driver = { .probe = pm8xxx_vib_probe, .driver = { .name = "pm8xxx-vib", - .pm = &pm8xxx_vib_pm_ops, + .pm = pm_sleep_ptr(&pm8xxx_vib_pm_ops), .of_match_table = pm8xxx_vib_id_table, }, }; diff --git a/drivers/input/misc/pmic8xxx-pwrkey.c b/drivers/input/misc/pmic8xxx-pwrkey.c index 0e818a3d28c5..89fb137e3715 100644 --- a/drivers/input/misc/pmic8xxx-pwrkey.c +++ b/drivers/input/misc/pmic8xxx-pwrkey.c @@ -100,7 +100,7 @@ static irqreturn_t pwrkey_release_irq(int irq, void *_pwr) return IRQ_HANDLED; } -static int __maybe_unused pmic8xxx_pwrkey_suspend(struct device *dev) +static int pmic8xxx_pwrkey_suspend(struct device *dev) { struct pmic8xxx_pwrkey *pwrkey = dev_get_drvdata(dev); @@ -110,7 +110,7 @@ static int __maybe_unused pmic8xxx_pwrkey_suspend(struct device *dev) return 0; } -static int __maybe_unused pmic8xxx_pwrkey_resume(struct device *dev) +static int pmic8xxx_pwrkey_resume(struct device *dev) { struct pmic8xxx_pwrkey *pwrkey = dev_get_drvdata(dev); @@ -120,7 +120,7 @@ static int __maybe_unused pmic8xxx_pwrkey_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(pm8xxx_pwr_key_pm_ops, +static DEFINE_SIMPLE_DEV_PM_OPS(pm8xxx_pwr_key_pm_ops, pmic8xxx_pwrkey_suspend, pmic8xxx_pwrkey_resume); static void pmic8xxx_pwrkey_shutdown(struct platform_device *pdev) @@ -442,7 +442,7 @@ static struct platform_driver pmic8xxx_pwrkey_driver = { .shutdown = pmic8xxx_pwrkey_shutdown, .driver = { .name = "pm8xxx-pwrkey", - .pm = &pm8xxx_pwr_key_pm_ops, + .pm = pm_sleep_ptr(&pm8xxx_pwr_key_pm_ops), .of_match_table = pm8xxx_pwr_key_id_table, }, }; diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c index d6b12477748a..3cf1812384e6 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c @@ -203,7 +203,7 @@ static int pwm_beeper_probe(struct platform_device *pdev) return 0; } -static int __maybe_unused pwm_beeper_suspend(struct device *dev) +static int pwm_beeper_suspend(struct device *dev) { struct pwm_beeper *beeper = dev_get_drvdata(dev); @@ -221,7 +221,7 @@ static int __maybe_unused pwm_beeper_suspend(struct device *dev) return 0; } -static int __maybe_unused pwm_beeper_resume(struct device *dev) +static int pwm_beeper_resume(struct device *dev) { struct pwm_beeper *beeper = dev_get_drvdata(dev); @@ -235,8 +235,8 @@ static int __maybe_unused pwm_beeper_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(pwm_beeper_pm_ops, - pwm_beeper_suspend, pwm_beeper_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(pwm_beeper_pm_ops, + pwm_beeper_suspend, pwm_beeper_resume); #ifdef CONFIG_OF static const struct of_device_id pwm_beeper_match[] = { @@ -250,7 +250,7 @@ static struct platform_driver pwm_beeper_driver = { .probe = pwm_beeper_probe, .driver = { .name = "pwm-beeper", - .pm = &pwm_beeper_pm_ops, + .pm = pm_sleep_ptr(&pwm_beeper_pm_ops), .of_match_table = of_match_ptr(pwm_beeper_match), }, }; diff --git a/drivers/input/misc/pwm-vibra.c b/drivers/input/misc/pwm-vibra.c index 81e777a04b88..d0e58a7cdfa3 100644 --- a/drivers/input/misc/pwm-vibra.c +++ b/drivers/input/misc/pwm-vibra.c @@ -222,7 +222,7 @@ static int pwm_vibrator_probe(struct platform_device *pdev) return 0; } -static int __maybe_unused pwm_vibrator_suspend(struct device *dev) +static int pwm_vibrator_suspend(struct device *dev) { struct pwm_vibrator *vibrator = dev_get_drvdata(dev); @@ -233,7 +233,7 @@ static int __maybe_unused pwm_vibrator_suspend(struct device *dev) return 0; } -static int __maybe_unused pwm_vibrator_resume(struct device *dev) +static int pwm_vibrator_resume(struct device *dev) { struct pwm_vibrator *vibrator = dev_get_drvdata(dev); @@ -243,8 +243,8 @@ static int __maybe_unused pwm_vibrator_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(pwm_vibrator_pm_ops, - pwm_vibrator_suspend, pwm_vibrator_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(pwm_vibrator_pm_ops, + pwm_vibrator_suspend, pwm_vibrator_resume); #ifdef CONFIG_OF static const struct of_device_id pwm_vibra_dt_match_table[] = { @@ -258,7 +258,7 @@ static struct platform_driver pwm_vibrator_driver = { .probe = pwm_vibrator_probe, .driver = { .name = "pwm-vibrator", - .pm = &pwm_vibrator_pm_ops, + .pm = pm_sleep_ptr(&pwm_vibrator_pm_ops), .of_match_table = of_match_ptr(pwm_vibra_dt_match_table), }, }; diff --git a/drivers/input/misc/regulator-haptic.c b/drivers/input/misc/regulator-haptic.c index a661e77545c5..02f73b7c0462 100644 --- a/drivers/input/misc/regulator-haptic.c +++ b/drivers/input/misc/regulator-haptic.c @@ -201,7 +201,7 @@ static int regulator_haptic_probe(struct platform_device *pdev) return 0; } -static int __maybe_unused regulator_haptic_suspend(struct device *dev) +static int regulator_haptic_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct regulator_haptic *haptic = platform_get_drvdata(pdev); @@ -220,7 +220,7 @@ static int __maybe_unused regulator_haptic_suspend(struct device *dev) return 0; } -static int __maybe_unused regulator_haptic_resume(struct device *dev) +static int regulator_haptic_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct regulator_haptic *haptic = platform_get_drvdata(pdev); @@ -239,7 +239,7 @@ static int __maybe_unused regulator_haptic_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(regulator_haptic_pm_ops, +static DEFINE_SIMPLE_DEV_PM_OPS(regulator_haptic_pm_ops, regulator_haptic_suspend, regulator_haptic_resume); static const struct of_device_id regulator_haptic_dt_match[] = { @@ -253,7 +253,7 @@ static struct platform_driver regulator_haptic_driver = { .driver = { .name = "regulator-haptic", .of_match_table = regulator_haptic_dt_match, - .pm = ®ulator_haptic_pm_ops, + .pm = pm_sleep_ptr(®ulator_haptic_pm_ops), }, }; module_platform_driver(regulator_haptic_driver); diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c index 6d613f2a017c..22ec62083065 100644 --- a/drivers/input/misc/rotary_encoder.c +++ b/drivers/input/misc/rotary_encoder.c @@ -317,7 +317,7 @@ static int rotary_encoder_probe(struct platform_device *pdev) return 0; } -static int __maybe_unused rotary_encoder_suspend(struct device *dev) +static int rotary_encoder_suspend(struct device *dev) { struct rotary_encoder *encoder = dev_get_drvdata(dev); unsigned int i; @@ -330,7 +330,7 @@ static int __maybe_unused rotary_encoder_suspend(struct device *dev) return 0; } -static int __maybe_unused rotary_encoder_resume(struct device *dev) +static int rotary_encoder_resume(struct device *dev) { struct rotary_encoder *encoder = dev_get_drvdata(dev); unsigned int i; @@ -343,8 +343,8 @@ static int __maybe_unused rotary_encoder_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(rotary_encoder_pm_ops, - rotary_encoder_suspend, rotary_encoder_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(rotary_encoder_pm_ops, + rotary_encoder_suspend, rotary_encoder_resume); #ifdef CONFIG_OF static const struct of_device_id rotary_encoder_of_match[] = { @@ -358,7 +358,7 @@ static struct platform_driver rotary_encoder_driver = { .probe = rotary_encoder_probe, .driver = { .name = DRV_NAME, - .pm = &rotary_encoder_pm_ops, + .pm = pm_sleep_ptr(&rotary_encoder_pm_ops), .of_match_table = of_match_ptr(rotary_encoder_of_match), } }; diff --git a/drivers/input/misc/stpmic1_onkey.c b/drivers/input/misc/stpmic1_onkey.c index d8dc2f2f8000..d5ebca7b90a5 100644 --- a/drivers/input/misc/stpmic1_onkey.c +++ b/drivers/input/misc/stpmic1_onkey.c @@ -142,7 +142,7 @@ static int stpmic1_onkey_probe(struct platform_device *pdev) return 0; } -static int __maybe_unused stpmic1_onkey_suspend(struct device *dev) +static int stpmic1_onkey_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct stpmic1_onkey *onkey = platform_get_drvdata(pdev); @@ -154,7 +154,7 @@ static int __maybe_unused stpmic1_onkey_suspend(struct device *dev) return 0; } -static int __maybe_unused stpmic1_onkey_resume(struct device *dev) +static int stpmic1_onkey_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct stpmic1_onkey *onkey = platform_get_drvdata(pdev); @@ -166,9 +166,9 @@ static int __maybe_unused stpmic1_onkey_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(stpmic1_onkey_pm, - stpmic1_onkey_suspend, - stpmic1_onkey_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(stpmic1_onkey_pm, + stpmic1_onkey_suspend, + stpmic1_onkey_resume); static const struct of_device_id of_stpmic1_onkey_match[] = { { .compatible = "st,stpmic1-onkey" }, @@ -182,7 +182,7 @@ static struct platform_driver stpmic1_onkey_driver = { .driver = { .name = "stpmic1_onkey", .of_match_table = of_match_ptr(of_stpmic1_onkey_match), - .pm = &stpmic1_onkey_pm, + .pm = pm_sleep_ptr(&stpmic1_onkey_pm), }, }; module_platform_driver(stpmic1_onkey_driver); diff --git a/drivers/input/misc/twl4030-vibra.c b/drivers/input/misc/twl4030-vibra.c index 5619996da86f..101548b35ee3 100644 --- a/drivers/input/misc/twl4030-vibra.c +++ b/drivers/input/misc/twl4030-vibra.c @@ -143,7 +143,7 @@ static void twl4030_vibra_close(struct input_dev *input) } /*** Module ***/ -static int __maybe_unused twl4030_vibra_suspend(struct device *dev) +static int twl4030_vibra_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct vibra_info *info = platform_get_drvdata(pdev); @@ -154,14 +154,14 @@ static int __maybe_unused twl4030_vibra_suspend(struct device *dev) return 0; } -static int __maybe_unused twl4030_vibra_resume(struct device *dev) +static int twl4030_vibra_resume(struct device *dev) { vibra_disable_leds(); return 0; } -static SIMPLE_DEV_PM_OPS(twl4030_vibra_pm_ops, - twl4030_vibra_suspend, twl4030_vibra_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(twl4030_vibra_pm_ops, + twl4030_vibra_suspend, twl4030_vibra_resume); static bool twl4030_vibra_check_coexist(struct device_node *parent) { @@ -234,7 +234,7 @@ static struct platform_driver twl4030_vibra_driver = { .probe = twl4030_vibra_probe, .driver = { .name = "twl4030-vibra", - .pm = &twl4030_vibra_pm_ops, + .pm = pm_sleep_ptr(&twl4030_vibra_pm_ops), }, }; module_platform_driver(twl4030_vibra_driver); diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c index bf6644927630..78f0b63e5c20 100644 --- a/drivers/input/misc/twl6040-vibra.c +++ b/drivers/input/misc/twl6040-vibra.c @@ -210,7 +210,7 @@ static void twl6040_vibra_close(struct input_dev *input) twl6040_vibra_disable(info); } -static int __maybe_unused twl6040_vibra_suspend(struct device *dev) +static int twl6040_vibra_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct vibra_info *info = platform_get_drvdata(pdev); @@ -223,7 +223,8 @@ static int __maybe_unused twl6040_vibra_suspend(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops, twl6040_vibra_suspend, NULL); +static DEFINE_SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops, + twl6040_vibra_suspend, NULL); static int twl6040_vibra_probe(struct platform_device *pdev) { @@ -354,7 +355,7 @@ static struct platform_driver twl6040_vibra_driver = { .probe = twl6040_vibra_probe, .driver = { .name = "twl6040-vibra", - .pm = &twl6040_vibra_pm_ops, + .pm = pm_sleep_ptr(&twl6040_vibra_pm_ops), }, }; module_platform_driver(twl6040_vibra_driver); diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c index 80dfd72a02d3..111cb70cde46 100644 --- a/drivers/input/misc/wistron_btns.c +++ b/drivers/input/misc/wistron_btns.c @@ -1295,7 +1295,6 @@ static int wistron_remove(struct platform_device *dev) return 0; } -#ifdef CONFIG_PM static int wistron_suspend(struct device *dev) { if (have_wifi) @@ -1330,14 +1329,11 @@ static const struct dev_pm_ops wistron_pm_ops = { .poweroff = wistron_suspend, .restore = wistron_resume, }; -#endif static struct platform_driver wistron_driver = { .driver = { .name = "wistron-bios", -#ifdef CONFIG_PM - .pm = &wistron_pm_ops, -#endif + .pm = pm_sleep_ptr(&wistron_pm_ops), }, .probe = wistron_probe, .remove = wistron_remove, |