From 292a089d78d3e2f7944e60bb897c977785a321e3 Mon Sep 17 00:00:00 2001 From: "Steven Rostedt (Google)" Date: Tue, 20 Dec 2022 13:45:19 -0500 Subject: treewide: Convert del_timer*() to timer_shutdown*() Due to several bugs caused by timers being re-armed after they are shutdown and just before they are freed, a new state of timers was added called "shutdown". After a timer is set to this state, then it can no longer be re-armed. The following script was run to find all the trivial locations where del_timer() or del_timer_sync() is called in the same function that the object holding the timer is freed. It also ignores any locations where the timer->function is modified between the del_timer*() and the free(), as that is not considered a "trivial" case. This was created by using a coccinelle script and the following commands: $ cat timer.cocci @@ expression ptr, slab; identifier timer, rfield; @@ ( - del_timer(&ptr->timer); + timer_shutdown(&ptr->timer); | - del_timer_sync(&ptr->timer); + timer_shutdown_sync(&ptr->timer); ) ... when strict when != ptr->timer ( kfree_rcu(ptr, rfield); | kmem_cache_free(slab, ptr); | kfree(ptr); ) $ spatch timer.cocci . > /tmp/t.patch $ patch -p1 < /tmp/t.patch Link: https://lore.kernel.org/lkml/20221123201306.823305113@linutronix.de/ Signed-off-by: Steven Rostedt (Google) Acked-by: Pavel Machek [ LED ] Acked-by: Kalle Valo [ wireless ] Acked-by: Paolo Abeni [ networking ] Signed-off-by: Linus Torvalds --- drivers/input/mouse/alps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/input/mouse') diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 4a6b33bbe7ea..989228b5a0a4 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c @@ -2970,7 +2970,7 @@ static void alps_disconnect(struct psmouse *psmouse) struct alps_data *priv = psmouse->private; psmouse_reset(psmouse); - del_timer_sync(&priv->timer); + timer_shutdown_sync(&priv->timer); if (priv->dev2) input_unregister_device(priv->dev2); if (!IS_ERR_OR_NULL(priv->dev3)) -- cgit v1.2.3 From b39f288a8416d427741def93dd4edcfe4911e7d0 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 2 Jan 2023 18:17:59 +0000 Subject: Input: elan_i2c_core - switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() SIMPLE_DEV_PM_OPS() is deprecated as it requires explicit protection against unused function warnings. The new combination of pm_sleep_ptr() and DEFINE_SIMPLE_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 __maybe_unused markings. Signed-off-by: Jonathan Cameron Cc: Raul E Rangel Cc: Hans de Goede Reviewed-by: Hans de Goede Reviewed-by: Linus Walleij Link: https://lore.kernel.org/r/20230102181842.718010-27-jic23@kernel.org Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/elan_i2c_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/input/mouse') diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index 76729ada1582..5f0d75a45c80 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -1328,7 +1328,7 @@ static int elan_probe(struct i2c_client *client) return 0; } -static int __maybe_unused elan_suspend(struct device *dev) +static int elan_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct elan_tp_data *data = i2c_get_clientdata(client); @@ -1365,7 +1365,7 @@ err: return ret; } -static int __maybe_unused elan_resume(struct device *dev) +static int elan_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct elan_tp_data *data = i2c_get_clientdata(client); @@ -1394,7 +1394,7 @@ err: return error; } -static SIMPLE_DEV_PM_OPS(elan_pm_ops, elan_suspend, elan_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(elan_pm_ops, elan_suspend, elan_resume); static const struct i2c_device_id elan_id[] = { { DRIVER_NAME, 0 }, @@ -1418,7 +1418,7 @@ MODULE_DEVICE_TABLE(of, elan_of_match); static struct i2c_driver elan_driver = { .driver = { .name = DRIVER_NAME, - .pm = &elan_pm_ops, + .pm = pm_sleep_ptr(&elan_pm_ops), .acpi_match_table = ACPI_PTR(elan_acpi_id), .of_match_table = of_match_ptr(elan_of_match), .probe_type = PROBE_PREFER_ASYNCHRONOUS, -- cgit v1.2.3 From 0ca5bc9556dc8a432bbfc0b297359d796dacc551 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 2 Jan 2023 18:18:00 +0000 Subject: Input: navpoint - switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() SIMPLE_DEV_PM_OPS() is deprecated as it requires explicit protection against unused function warnings. The new combination of pm_sleep_ptr() and DEFINE_SIMPLE_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 __maybe_unused markings. Signed-off-by: Jonathan Cameron Reviewed-by: Linus Walleij Link: https://lore.kernel.org/r/20230102181842.718010-28-jic23@kernel.org Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/navpoint.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers/input/mouse') diff --git a/drivers/input/mouse/navpoint.c b/drivers/input/mouse/navpoint.c index 4d67575bb276..2b7b86eef280 100644 --- a/drivers/input/mouse/navpoint.c +++ b/drivers/input/mouse/navpoint.c @@ -315,7 +315,7 @@ static int navpoint_remove(struct platform_device *pdev) return 0; } -static int __maybe_unused navpoint_suspend(struct device *dev) +static int navpoint_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct navpoint *navpoint = platform_get_drvdata(pdev); @@ -329,7 +329,7 @@ static int __maybe_unused navpoint_suspend(struct device *dev) return 0; } -static int __maybe_unused navpoint_resume(struct device *dev) +static int navpoint_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct navpoint *navpoint = platform_get_drvdata(pdev); @@ -343,14 +343,15 @@ static int __maybe_unused navpoint_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(navpoint_pm_ops, navpoint_suspend, navpoint_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(navpoint_pm_ops, + navpoint_suspend, navpoint_resume); static struct platform_driver navpoint_driver = { .probe = navpoint_probe, .remove = navpoint_remove, .driver = { .name = "navpoint", - .pm = &navpoint_pm_ops, + .pm = pm_sleep_ptr(&navpoint_pm_ops), }, }; -- cgit v1.2.3 From 18b8fe43d5c3e76361884b57a3b1c2acf6922c4b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 2 Jan 2023 18:18:01 +0000 Subject: Input: synaptics_i2c - switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() SIMPLE_DEV_PM_OPS() is deprecated as it requires explicit protection against unused function warnings. The new combination of pm_sleep_ptr() and DEFINE_SIMPLE_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 __maybe_unused markings. Signed-off-by: Jonathan Cameron Reviewed-by: Linus Walleij Link: https://lore.kernel.org/r/20230102181842.718010-29-jic23@kernel.org Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/synaptics_i2c.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/input/mouse') diff --git a/drivers/input/mouse/synaptics_i2c.c b/drivers/input/mouse/synaptics_i2c.c index 6487c8c60d5e..068692a8aba5 100644 --- a/drivers/input/mouse/synaptics_i2c.c +++ b/drivers/input/mouse/synaptics_i2c.c @@ -597,7 +597,7 @@ static void synaptics_i2c_remove(struct i2c_client *client) kfree(touch); } -static int __maybe_unused synaptics_i2c_suspend(struct device *dev) +static int synaptics_i2c_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct synaptics_i2c *touch = i2c_get_clientdata(client); @@ -610,7 +610,7 @@ static int __maybe_unused synaptics_i2c_suspend(struct device *dev) return 0; } -static int __maybe_unused synaptics_i2c_resume(struct device *dev) +static int synaptics_i2c_resume(struct device *dev) { int ret; struct i2c_client *client = to_i2c_client(dev); @@ -626,8 +626,8 @@ static int __maybe_unused synaptics_i2c_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(synaptics_i2c_pm, synaptics_i2c_suspend, - synaptics_i2c_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(synaptics_i2c_pm, synaptics_i2c_suspend, + synaptics_i2c_resume); static const struct i2c_device_id synaptics_i2c_id_table[] = { { "synaptics_i2c", 0 }, @@ -647,7 +647,7 @@ static struct i2c_driver synaptics_i2c_driver = { .driver = { .name = DRIVER_NAME, .of_match_table = of_match_ptr(synaptics_i2c_of_match), - .pm = &synaptics_i2c_pm, + .pm = pm_sleep_ptr(&synaptics_i2c_pm), }, .probe_new = synaptics_i2c_probe, -- cgit v1.2.3 From 28bbeca2f627267f0c9a445525296b63a2ad73b4 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 14 Jan 2023 17:16:05 +0000 Subject: Input: cyapa - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() and pm_ptr() SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() are deprecated as they require explicit protection against unused function warnings. The new combination of pm_ptr() and SYSTEM_SLEEP_PM_OPS()/ RUNTIME_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 __maybe_unused markings. Signed-off-by: Jonathan Cameron Link: https://lore.kernel.org/r/20230114171620.42891-2-jic23@kernel.org Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/cyapa.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/input/mouse') diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c index 7e88a6ec7989..dd7b0d70d791 100644 --- a/drivers/input/mouse/cyapa.c +++ b/drivers/input/mouse/cyapa.c @@ -1349,7 +1349,7 @@ static int cyapa_probe(struct i2c_client *client) return 0; } -static int __maybe_unused cyapa_suspend(struct device *dev) +static int cyapa_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct cyapa *cyapa = i2c_get_clientdata(client); @@ -1397,7 +1397,7 @@ static int __maybe_unused cyapa_suspend(struct device *dev) return 0; } -static int __maybe_unused cyapa_resume(struct device *dev) +static int cyapa_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct cyapa *cyapa = i2c_get_clientdata(client); @@ -1424,7 +1424,7 @@ static int __maybe_unused cyapa_resume(struct device *dev) return 0; } -static int __maybe_unused cyapa_runtime_suspend(struct device *dev) +static int cyapa_runtime_suspend(struct device *dev) { struct cyapa *cyapa = dev_get_drvdata(dev); int error; @@ -1439,7 +1439,7 @@ static int __maybe_unused cyapa_runtime_suspend(struct device *dev) return 0; } -static int __maybe_unused cyapa_runtime_resume(struct device *dev) +static int cyapa_runtime_resume(struct device *dev) { struct cyapa *cyapa = dev_get_drvdata(dev); int error; @@ -1453,8 +1453,8 @@ static int __maybe_unused cyapa_runtime_resume(struct device *dev) } static const struct dev_pm_ops cyapa_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(cyapa_suspend, cyapa_resume) - SET_RUNTIME_PM_OPS(cyapa_runtime_suspend, cyapa_runtime_resume, NULL) + SYSTEM_SLEEP_PM_OPS(cyapa_suspend, cyapa_resume) + RUNTIME_PM_OPS(cyapa_runtime_suspend, cyapa_runtime_resume, NULL) }; static const struct i2c_device_id cyapa_id_table[] = { @@ -1484,7 +1484,7 @@ MODULE_DEVICE_TABLE(of, cyapa_of_match); static struct i2c_driver cyapa_driver = { .driver = { .name = "cyapa", - .pm = &cyapa_pm_ops, + .pm = pm_ptr(&cyapa_pm_ops), .acpi_match_table = ACPI_PTR(cyapa_acpi_id), .of_match_table = of_match_ptr(cyapa_of_match), }, -- cgit v1.2.3