aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/alarmtimer.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/alarmtimer.h')
-rw-r--r--include/linux/alarmtimer.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/include/linux/alarmtimer.h b/include/linux/alarmtimer.h
index c854a8efa863..304124a6c982 100644
--- a/include/linux/alarmtimer.h
+++ b/include/linux/alarmtimer.h
@@ -18,6 +18,11 @@ enum alarmtimer_restart {
18 ALARMTIMER_RESTART, 18 ALARMTIMER_RESTART,
19}; 19};
20 20
21
22#define ALARMTIMER_STATE_INACTIVE 0x00
23#define ALARMTIMER_STATE_ENQUEUED 0x01
24#define ALARMTIMER_STATE_CALLBACK 0x02
25
21/** 26/**
22 * struct alarm - Alarm timer structure 27 * struct alarm - Alarm timer structure
23 * @node: timerqueue node for adding to the event list this value 28 * @node: timerqueue node for adding to the event list this value
@@ -32,7 +37,7 @@ struct alarm {
32 struct timerqueue_node node; 37 struct timerqueue_node node;
33 enum alarmtimer_restart (*function)(struct alarm *, ktime_t now); 38 enum alarmtimer_restart (*function)(struct alarm *, ktime_t now);
34 enum alarmtimer_type type; 39 enum alarmtimer_type type;
35 bool enabled; 40 int state;
36 void *data; 41 void *data;
37}; 42};
38 43
@@ -43,4 +48,31 @@ void alarm_cancel(struct alarm *alarm);
43 48
44u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval); 49u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);
45 50
51/*
52 * A alarmtimer is active, when it is enqueued into timerqueue or the
53 * callback function is running.
54 */
55static inline int alarmtimer_active(const struct alarm *timer)
56{
57 return timer->state != ALARMTIMER_STATE_INACTIVE;
58}
59
60/*
61 * Helper function to check, whether the timer is on one of the queues
62 */
63static inline int alarmtimer_is_queued(struct alarm *timer)
64{
65 return timer->state & ALARMTIMER_STATE_ENQUEUED;
66}
67
68/*
69 * Helper function to check, whether the timer is running the callback
70 * function
71 */
72static inline int alarmtimer_callback_running(struct alarm *timer)
73{
74 return timer->state & ALARMTIMER_STATE_CALLBACK;
75}
76
77
46#endif 78#endif