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.h51
1 files changed, 45 insertions, 6 deletions
diff --git a/include/linux/alarmtimer.h b/include/linux/alarmtimer.h
index c5d6095b46f8..975009e1cbe6 100644
--- a/include/linux/alarmtimer.h
+++ b/include/linux/alarmtimer.h
@@ -13,6 +13,16 @@ enum alarmtimer_type {
13 ALARM_NUMTYPE, 13 ALARM_NUMTYPE,
14}; 14};
15 15
16enum alarmtimer_restart {
17 ALARMTIMER_NORESTART,
18 ALARMTIMER_RESTART,
19};
20
21
22#define ALARMTIMER_STATE_INACTIVE 0x00
23#define ALARMTIMER_STATE_ENQUEUED 0x01
24#define ALARMTIMER_STATE_CALLBACK 0x02
25
16/** 26/**
17 * struct alarm - Alarm timer structure 27 * struct alarm - Alarm timer structure
18 * @node: timerqueue node for adding to the event list this value 28 * @node: timerqueue node for adding to the event list this value
@@ -25,16 +35,45 @@ enum alarmtimer_type {
25 */ 35 */
26struct alarm { 36struct alarm {
27 struct timerqueue_node node; 37 struct timerqueue_node node;
28 ktime_t period; 38 enum alarmtimer_restart (*function)(struct alarm *, ktime_t now);
29 void (*function)(struct alarm *);
30 enum alarmtimer_type type; 39 enum alarmtimer_type type;
31 bool enabled; 40 int state;
32 void *data; 41 void *data;
33}; 42};
34 43
35void alarm_init(struct alarm *alarm, enum alarmtimer_type type, 44void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
36 void (*function)(struct alarm *)); 45 enum alarmtimer_restart (*function)(struct alarm *, ktime_t));
37void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period); 46void alarm_start(struct alarm *alarm, ktime_t start);
38void alarm_cancel(struct alarm *alarm); 47int alarm_try_to_cancel(struct alarm *alarm);
48int alarm_cancel(struct alarm *alarm);
49
50u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);
51
52/*
53 * A alarmtimer is active, when it is enqueued into timerqueue or the
54 * callback function is running.
55 */
56static inline int alarmtimer_active(const struct alarm *timer)
57{
58 return timer->state != ALARMTIMER_STATE_INACTIVE;
59}
60
61/*
62 * Helper function to check, whether the timer is on one of the queues
63 */
64static inline int alarmtimer_is_queued(struct alarm *timer)
65{
66 return timer->state & ALARMTIMER_STATE_ENQUEUED;
67}
68
69/*
70 * Helper function to check, whether the timer is running the callback
71 * function
72 */
73static inline int alarmtimer_callback_running(struct alarm *timer)
74{
75 return timer->state & ALARMTIMER_STATE_CALLBACK;
76}
77
39 78
40#endif 79#endif