]> Pileus Git - ~andy/linux/blob - include/linux/alarmtimer.h
alarmtimers: Add alarm_forward functionality
[~andy/linux] / include / linux / alarmtimer.h
1 #ifndef _LINUX_ALARMTIMER_H
2 #define _LINUX_ALARMTIMER_H
3
4 #include <linux/time.h>
5 #include <linux/hrtimer.h>
6 #include <linux/timerqueue.h>
7 #include <linux/rtc.h>
8
9 enum alarmtimer_type {
10         ALARM_REALTIME,
11         ALARM_BOOTTIME,
12
13         ALARM_NUMTYPE,
14 };
15
16 enum alarmtimer_restart {
17         ALARMTIMER_NORESTART,
18         ALARMTIMER_RESTART,
19 };
20
21 /**
22  * struct alarm - Alarm timer structure
23  * @node:       timerqueue node for adding to the event list this value
24  *              also includes the expiration time.
25  * @period:     Period for recuring alarms
26  * @function:   Function pointer to be executed when the timer fires.
27  * @type:       Alarm type (BOOTTIME/REALTIME)
28  * @enabled:    Flag that represents if the alarm is set to fire or not
29  * @data:       Internal data value.
30  */
31 struct alarm {
32         struct timerqueue_node  node;
33         ktime_t                 period;
34         enum alarmtimer_restart (*function)(struct alarm *, ktime_t now);
35         enum alarmtimer_type    type;
36         bool                    enabled;
37         void                    *data;
38 };
39
40 void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
41                 enum alarmtimer_restart (*function)(struct alarm *, ktime_t));
42 void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period);
43 void alarm_cancel(struct alarm *alarm);
44
45 u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);
46
47 #endif