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

Input: cyttsp4 - use EXPORT_GPL_RUNTIME_DEV_PM_OPS()

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>

authored by

Jonathan Cameron and committed by
Dmitry Torokhov
ebbdbef2 6470215b

+4 -9
+2 -7
drivers/input/touchscreen/cyttsp4_core.c
··· 1744 1744 kfree(si->btn_rec_data); 1745 1745 } 1746 1746 1747 - #ifdef CONFIG_PM 1748 1747 static int cyttsp4_core_sleep(struct cyttsp4 *cd) 1749 1748 { 1750 1749 int rc; ··· 1876 1877 1877 1878 return 0; 1878 1879 } 1879 - #endif 1880 1880 1881 - const struct dev_pm_ops cyttsp4_pm_ops = { 1882 - SET_SYSTEM_SLEEP_PM_OPS(cyttsp4_core_suspend, cyttsp4_core_resume) 1883 - SET_RUNTIME_PM_OPS(cyttsp4_core_suspend, cyttsp4_core_resume, NULL) 1884 - }; 1885 - EXPORT_SYMBOL_GPL(cyttsp4_pm_ops); 1881 + EXPORT_GPL_RUNTIME_DEV_PM_OPS(cyttsp4_pm_ops, 1882 + cyttsp4_core_suspend, cyttsp4_core_resume, NULL); 1886 1883 1887 1884 static int cyttsp4_mt_open(struct input_dev *input) 1888 1885 {
+1 -1
drivers/input/touchscreen/cyttsp4_i2c.c
··· 58 58 static struct i2c_driver cyttsp4_i2c_driver = { 59 59 .driver = { 60 60 .name = CYTTSP4_I2C_NAME, 61 - .pm = &cyttsp4_pm_ops, 61 + .pm = pm_ptr(&cyttsp4_pm_ops), 62 62 }, 63 63 .probe_new = cyttsp4_i2c_probe, 64 64 .remove = cyttsp4_i2c_remove,
+1 -1
drivers/input/touchscreen/cyttsp4_spi.c
··· 173 173 static struct spi_driver cyttsp4_spi_driver = { 174 174 .driver = { 175 175 .name = CYTTSP4_SPI_NAME, 176 - .pm = &cyttsp4_pm_ops, 176 + .pm = pm_ptr(&cyttsp4_pm_ops), 177 177 }, 178 178 .probe = cyttsp4_spi_probe, 179 179 .remove = cyttsp4_spi_remove,