1
2 #ifndef _LINUX_ALARMTIMER_H
3 #define _LINUX_ALARMTIMER_H
4
5 #include <linux/time.h>
6 #include <linux/hrtimer.h>
7 #include <linux/timerqueue.h>
8
9 struct rtc_device;
10
11 enum alarmtimer_type {
12 ALARM_REALTIME,
13 ALARM_BOOTTIME,
14
15
16 ALARM_NUMTYPE,
17
18
19 ALARM_REALTIME_FREEZER,
20 ALARM_BOOTTIME_FREEZER,
21 };
22
23 enum alarmtimer_restart {
24 ALARMTIMER_NORESTART,
25 ALARMTIMER_RESTART,
26 };
27
28
29 #define ALARMTIMER_STATE_INACTIVE 0x00
30 #define ALARMTIMER_STATE_ENQUEUED 0x01
31
32
33
34
35
36
37
38
39
40
41
42 struct alarm {
43 struct timerqueue_node node;
44 struct hrtimer timer;
45 enum alarmtimer_restart (*function)(struct alarm *, ktime_t now);
46 enum alarmtimer_type type;
47 int state;
48 void *data;
49 };
50
51 void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
52 enum alarmtimer_restart (*function)(struct alarm *, ktime_t));
53 void alarm_start(struct alarm *alarm, ktime_t start);
54 void alarm_start_relative(struct alarm *alarm, ktime_t start);
55 void alarm_restart(struct alarm *alarm);
56 int alarm_try_to_cancel(struct alarm *alarm);
57 int alarm_cancel(struct alarm *alarm);
58
59 u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);
60 u64 alarm_forward_now(struct alarm *alarm, ktime_t interval);
61 ktime_t alarm_expires_remaining(const struct alarm *alarm);
62
63
64 struct rtc_device *alarmtimer_get_rtcdev(void);
65
66 #endif