[PATCH] Coccinelle: api: Add SmPL script “pm_runtime_mark_last_busy-deletion.cocci”

Markus Elfring posted 1 patch 3 weeks, 3 days ago
.../pm_runtime_mark_last_busy-deletion.cocci  | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 scripts/coccinelle/api/pm_runtime_mark_last_busy-deletion.cocci
[PATCH] Coccinelle: api: Add SmPL script “pm_runtime_mark_last_busy-deletion.cocci”
Posted by Markus Elfring 3 weeks, 3 days ago
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 13 Mar 2026 18:15:11 +0100

The device's last busy timestamp was set in a wrapper function since
the commit b3db492e8335417dfd66c1fa2ea08e1d2f7b6736 ("PM: runtime:
Mark last busy stamp in pm_runtime_put_autosuspend()").
Thus delete pm_runtime_mark_last_busy() calls before
pm_runtime_put_autosuspend() calls.
Provide design options for the adjustment of affected source code
by the means of the semantic patch language (Coccinelle software).

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../pm_runtime_mark_last_busy-deletion.cocci  | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 scripts/coccinelle/api/pm_runtime_mark_last_busy-deletion.cocci

diff --git a/scripts/coccinelle/api/pm_runtime_mark_last_busy-deletion.cocci b/scripts/coccinelle/api/pm_runtime_mark_last_busy-deletion.cocci
new file mode 100644
index 000000000000..fa17fd8ea43b
--- /dev/null
+++ b/scripts/coccinelle/api/pm_runtime_mark_last_busy-deletion.cocci
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0
+/// Omit pm_runtime_mark_last_busy() call before pm_runtime_put_autosuspend().
+//
+// Keywords: wrapper function access timestamp autosuspend
+// Confidence: High
+// Options: --no-includes --include-headers
+
+virtual context, patch, report, org
+
+@depends on context@
+expression e;
+@@
+*pm_runtime_mark_last_busy(e);
+ pm_runtime_put_autosuspend(e);
+
+@depends on patch@
+expression e;
+@@
+-pm_runtime_mark_last_busy(e);
+ pm_runtime_put_autosuspend(e);
+
+@x depends on org || report@
+expression e;
+position p;
+@@
+ pm_runtime_mark_last_busy@p(e);
+ pm_runtime_put_autosuspend(e);
+
+@script:python depends on org@
+p << x.p;
+@@
+coccilib.org.print_todo(p[0], "WARNING: Delete pm_runtime_mark_last_busy() call before pm_runtime_put_autosuspend()")
+
+@script:python depends on report@
+p << x.p;
+@@
+coccilib.report.print_report(p[0], "WARNING: Delete pm_runtime_mark_last_busy() call before pm_runtime_put_autosuspend()")
-- 
2.53.0