Skip to contentSkip to conversation

headers: Add timer_shutdown_sync()

PATCH New Yi Cong 1 participant 1 message May 12

lore
Share & tools
lore

Yi Cong

author
#0 lore raw

PATCH 1/1 headers: Add timer_shutdown_sync()

From: Yi Cong <[email protected]>

This function need delete timer and set functionm callback to NULL

---
 backport/backport-include/linux/timer.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
backport/backport-include/linux/timer.h +14 -0
index 14467fb6..36e15340 100644
@@ -79,4 +79,18 @@ static inline int timer_delete_sync(struct timer_list *timer)
 }
 #endif /* < 6.1.84 */
 
+#if LINUX_VERSION_IS_LESS(6,2,0)
+static inline int timer_shutdown_sync(struct timer_list *timer)
+{
+    int ret = del_timer_sync(timer);
+    /*
+     * Emulate shutdown semantics: mark as dead to prevent accidental reuse.
+     * Safe to do after del_timer_sync() because timer is no longer
+     * referenced by the timer subsystem.
+     */
+    timer->function = NULL;
+    return ret;
+}
+#endif
+
 #endif /* _BACKPORT_TIMER_H */
Signature · 1 line
2.25.1