xref: /linux/drivers/gpu/drm/i915/i915_timer_util.h (revision 58809f614e0e3f4e12b489bddf680bfeb31c0a20)
1 /* SPDX-License-Identifier: MIT */
2 /* Copyright © 2025 Intel Corporation */
3 
4 #ifndef __I915_TIMER_UTIL_H__
5 #define __I915_TIMER_UTIL_H__
6 
7 #include <linux/timer.h>
8 #include <asm/rwonce.h>
9 
10 void cancel_timer(struct timer_list *t);
11 void set_timer_ms(struct timer_list *t, unsigned long timeout);
12 
13 static inline bool timer_active(const struct timer_list *t)
14 {
15 	return READ_ONCE(t->expires);
16 }
17 
18 static inline bool timer_expired(const struct timer_list *t)
19 {
20 	return timer_active(t) && !timer_pending(t);
21 }
22 
23 #endif /* __I915_TIMER_UTIL_H__ */
24