]> git.dujemihanovic.xyz Git - linux.git/commitdiff
Input: cyttsp4 - use EXPORT_GPL_RUNTIME_DEV_PM_OPS()
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 14 Jan 2023 17:16:14 +0000 (17:16 +0000)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 27 Jan 2023 22:49:53 +0000 (14:49 -0800)
SET_SYSTEM_SLEEP_PM_OPS() and RUNTIME_PM_OPS() are deprecated as
they requires explicit protection against unused function warnings.
The new combination of pm_ptr() EXPORT_GPL_RUNTIME_DEV_PM_OPS()
allows the compiler to see the functions, thus suppressing the
warning, but still allowing the unused code to be
removed. Thus also drop the #ifdef guards.

Note that we are replacing an unconditional call to the suspend
and resume functions for sleep use cases with one via
pm_runtime_force_suspend() / pm_runtime_force_resume() that only
do anything to the device if we are not already in the appropriate
runtime suspended state.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
--

I 'think' this should be fine in that it can only reduce the number
of unnecessary suspends.  If anyone can test that would be great.

Link: https://lore.kernel.org/r/20230114171620.42891-11-jic23@kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/cyttsp4_core.c
drivers/input/touchscreen/cyttsp4_i2c.c
drivers/input/touchscreen/cyttsp4_spi.c

index dccbcb942fe59affc47488e83343a9b9cec576e7..0cd6f626adec5d624cd5fb88adec356d2158d85b 100644 (file)
@@ -1744,7 +1744,6 @@ static void cyttsp4_free_si_ptrs(struct cyttsp4 *cd)
        kfree(si->btn_rec_data);
 }
 
-#ifdef CONFIG_PM
 static int cyttsp4_core_sleep(struct cyttsp4 *cd)
 {
        int rc;
@@ -1877,13 +1876,9 @@ static int cyttsp4_core_resume(struct device *dev)
 
        return 0;
 }
-#endif
 
-const struct dev_pm_ops cyttsp4_pm_ops = {
-       SET_SYSTEM_SLEEP_PM_OPS(cyttsp4_core_suspend, cyttsp4_core_resume)
-       SET_RUNTIME_PM_OPS(cyttsp4_core_suspend, cyttsp4_core_resume, NULL)
-};
-EXPORT_SYMBOL_GPL(cyttsp4_pm_ops);
+EXPORT_GPL_RUNTIME_DEV_PM_OPS(cyttsp4_pm_ops,
+                             cyttsp4_core_suspend, cyttsp4_core_resume, NULL);
 
 static int cyttsp4_mt_open(struct input_dev *input)
 {
index c260bab0c62c77a3bf5405527235ef5365516358..ec7a4779f3fbf8f3c762efe191dcc7190439692f 100644 (file)
@@ -58,7 +58,7 @@ MODULE_DEVICE_TABLE(i2c, cyttsp4_i2c_id);
 static struct i2c_driver cyttsp4_i2c_driver = {
        .driver = {
                .name   = CYTTSP4_I2C_NAME,
-               .pm     = &cyttsp4_pm_ops,
+               .pm     = pm_ptr(&cyttsp4_pm_ops),
        },
        .probe_new      = cyttsp4_i2c_probe,
        .remove         = cyttsp4_i2c_remove,
index 5d7db84f2749c06d3723245dc2556b5ccf39dc2c..944fbbe9113e13df4c7d1a328735978b878987df 100644 (file)
@@ -173,7 +173,7 @@ static void cyttsp4_spi_remove(struct spi_device *spi)
 static struct spi_driver cyttsp4_spi_driver = {
        .driver = {
                .name   = CYTTSP4_SPI_NAME,
-               .pm     = &cyttsp4_pm_ops,
+               .pm     = pm_ptr(&cyttsp4_pm_ops),
        },
        .probe  = cyttsp4_spi_probe,
        .remove = cyttsp4_spi_remove,